Skip to content

Commit

Permalink
Merge pull request #38928 from nextcloud/fix/missing-systemtags-index
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelklehr committed Jun 22, 2023
2 parents a3fe1ad + e774708 commit 618c3a4
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 @@ -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');
}
}
}
);

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 @@ -472,6 +472,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 @@ -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')) {
Expand Down

0 comments on commit 618c3a4

Please sign in to comment.