Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB mounts table: Add index for mount_provider_class #33405

Merged
merged 1 commit into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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