Skip to content

Commit

Permalink
DB mounts table: Add index for mount_provider_class
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
  • Loading branch information
marcelklehr committed Aug 1, 2022
1 parent 52dc51c commit 047cc70
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 @@ -225,6 +225,13 @@ function (GenericEvent $event) use ($container) {
$subject->addHintForMissingSubject($table->getName(), 'preferences_app_key');
}
}

if ($schema->hasTable('mounts')) {
$table = $schema->getTable('mounts');
if (!$table->hasIndex('mounts_class_index')) {
$subject->addHintForMissingSubject($table->getName(), 'mounts_class_index');
}
}
}
);

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 @@ -444,6 +444,19 @@ private function addCoreIndexes(OutputInterface $output, bool $dryRun): void {
}
}

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

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

if (!$updated) {
$output->writeln('<info>Done.</info>');
}
Expand Down
1 change: 1 addition & 0 deletions core/Migrations/Version24000Date20220202150027.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
'notnull' => false,
'length' => 128,
]);
$table->addIndex(['mount_provider_class'], 'mounts_class_index');
return $schema;
}
return null;
Expand Down

0 comments on commit 047cc70

Please sign in to comment.