Skip to content

Commit

Permalink
Merge pull request #38962 from nextcloud/fix/missing-systemtags-index…
Browse files Browse the repository at this point in the history
…-stable25

[stable25] fix(systemtags): Add missing systemtags index
  • Loading branch information
blizzz authored Jun 30, 2023
2 parents 4fb908b + 1448063 commit 2027372
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
}
);

Expand Down
13 changes: 13 additions & 0 deletions core/Command/Db/AddMissingIndices.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,19 @@ private function addCoreIndexes(OutputInterface $output, bool $dryRun): void {
}
}

$output->writeln('<info>Check indices of the oc_systemtag_object_mapping table.</info>');
if ($schema->hasTable('oc_systemtag_object_mapping')) {
$table = $schema->getTable('oc_systemtag_object_mapping');
if (!$table->hasIndex('systag_by_tagid')) {
$output->writeln('<info>Adding systag_by_tagid index to the oc_systemtag_object_mapping table, this can take some time...</info>');

$table->addIndex(['systemtagid', 'objecttype'], 'systag_by_tagid');
$this->connection->migrateToSchema($schema->getWrappedSchema());
$updated = true;
$output->writeln('<info>oc_systemtag_object_mapping table updated successfully.</info>');
}
}

if (!$updated) {
$output->writeln('<info>Done.</info>');
}
Expand Down
1 change: 1 addition & 0 deletions core/Migrations/Version13000Date20170718121200.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down

0 comments on commit 2027372

Please sign in to comment.