Skip to content

Commit b43e45d

Browse files
Merge pull request #38960 from nextcloud/fix/missing-systemtags-index-stable27
[stable27] fix(systemtags): Add missing systemtags index
2 parents e211096 + 7226a9a commit b43e45d

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

core/Application.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,13 @@ function (GenericEvent $event) use ($container) {
243243
$subject->addHintForMissingSubject($table->getName(), 'mounts_user_root_path_index');
244244
}
245245
}
246+
247+
if ($schema->hasTable('systemtag_object_mapping')) {
248+
$table = $schema->getTable('systemtag_object_mapping');
249+
if (!$table->hasIndex('systag_by_tagid')) {
250+
$subject->addHintForMissingSubject($table->getName(), 'systag_by_tagid');
251+
}
252+
}
246253
}
247254
);
248255

core/Command/Db/AddMissingIndices.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,19 @@ private function addCoreIndexes(OutputInterface $output, bool $dryRun): void {
475475
}
476476
}
477477

478+
$output->writeln('<info>Check indices of the oc_systemtag_object_mapping table.</info>');
479+
if ($schema->hasTable('oc_systemtag_object_mapping')) {
480+
$table = $schema->getTable('oc_systemtag_object_mapping');
481+
if (!$table->hasIndex('systag_by_tagid')) {
482+
$output->writeln('<info>Adding systag_by_tagid index to the oc_systemtag_object_mapping table, this can take some time...</info>');
483+
484+
$table->addIndex(['systemtagid', 'objecttype'], 'systag_by_tagid');
485+
$this->connection->migrateToSchema($schema->getWrappedSchema());
486+
$updated = true;
487+
$output->writeln('<info>oc_systemtag_object_mapping table updated successfully.</info>');
488+
}
489+
}
490+
478491
if (!$updated) {
479492
$output->writeln('<info>Done.</info>');
480493
}

core/Migrations/Version13000Date20170718121200.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
754754
]);
755755
$table->setPrimaryKey(['objecttype', 'objectid', 'systemtagid'], 'som_pk');
756756
// $table->addUniqueIndex(['objecttype', 'objectid', 'systemtagid'], 'mapping');
757+
$table->addIndex(['systemtagid', 'objecttype'], 'systag_by_tagid');
757758
}
758759

759760
if (!$schema->hasTable('systemtag_group')) {

0 commit comments

Comments
 (0)