diff --git a/core/Application.php b/core/Application.php index cb961d3986804..83326f1478f5f 100644 --- a/core/Application.php +++ b/core/Application.php @@ -239,6 +239,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 41f53cd54cf20..906e8c95ba46d 100644 --- a/core/Migrations/Version13000Date20170718121200.php +++ b/core/Migrations/Version13000Date20170718121200.php @@ -755,6 +755,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')) {