diff --git a/core/Application.php b/core/Application.php
index 2e35461015472..592e092966681 100644
--- a/core/Application.php
+++ b/core/Application.php
@@ -243,6 +243,13 @@ function (GenericEvent $event) use ($container) {
$subject->addHintForMissingSubject($table->getName(), 'mounts_user_root_path_index');
}
}
+
+ if ($schema->hasTable('systemtag_object_mapping')) {
+ $table = $schema->getTable('systemtag_object_mapping');
+ if (!$table->hasIndex('systag_by_tagid')) {
+ $subject->addHintForMissingSubject($table->getName(), 'systag_by_tagid');
+ }
+ }
}
);
diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php
index b317f44b49930..452bcbad5dc05 100644
--- a/core/Command/Db/AddMissingIndices.php
+++ b/core/Command/Db/AddMissingIndices.php
@@ -475,6 +475,19 @@ private function addCoreIndexes(OutputInterface $output, bool $dryRun): void {
}
}
+ $output->writeln('Check indices of the oc_systemtag_object_mapping table.');
+ if ($schema->hasTable('oc_systemtag_object_mapping')) {
+ $table = $schema->getTable('oc_systemtag_object_mapping');
+ if (!$table->hasIndex('systag_by_tagid')) {
+ $output->writeln('Adding systag_by_tagid index to the oc_systemtag_object_mapping table, this can take some time...');
+
+ $table->addIndex(['systemtagid', 'objecttype'], 'systag_by_tagid');
+ $this->connection->migrateToSchema($schema->getWrappedSchema());
+ $updated = true;
+ $output->writeln('oc_systemtag_object_mapping table updated successfully.');
+ }
+ }
+
if (!$updated) {
$output->writeln('Done.');
}
diff --git a/core/Migrations/Version13000Date20170718121200.php b/core/Migrations/Version13000Date20170718121200.php
index 34a249814fbc2..05cdbcfd6b5f0 100644
--- a/core/Migrations/Version13000Date20170718121200.php
+++ b/core/Migrations/Version13000Date20170718121200.php
@@ -754,6 +754,7 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
]);
$table->setPrimaryKey(['objecttype', 'objectid', 'systemtagid'], 'som_pk');
// $table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping');
+ $table->addIndex(['systemtagid', 'objecttype'], 'systag_by_tagid');
}
if (!$schema->hasTable('systemtag_group')) {