DB mounts table: Add index for mount_provider_class

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
Marcel Klehr 2022-07-29 14:43:26 +02:00
parent d48f13a3c6
commit 67af99e14e
3 changed files with 24 additions and 0 deletions

View file

@ -218,6 +218,13 @@ class Application extends App {
$subject->addHintForMissingSubject($table->getName(), 'direct_edit_timestamp');
}
}
if ($schema->hasTable('mounts')) {
$table = $schema->getTable('mounts');
if (!$table->hasIndex('mounts_class_index')) {
$subject->addHintForMissingSubject($table->getName(), 'mounts_class_index');
}
}
}
);

View file

@ -435,6 +435,22 @@ class AddMissingIndices extends Command {
}
}
$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');
$sqlQueries = $this->connection->migrateToSchema($schema->getWrappedSchema(), $dryRun);
if ($dryRun && $sqlQueries !== null) {
$output->writeln($sqlQueries);
}
$updated = true;
$output->writeln('<info>oc_mounts table updated successfully.</info>');
}
}
if (!$updated) {
$output->writeln('<info>Done.</info>');
}

View file

@ -30,6 +30,7 @@ class Version24000Date20220202150027 extends SimpleMigrationStep {
'notnull' => false,
'length' => 128,
]);
$table->addIndex(['mount_provider_class'], 'mounts_class_index');
return $schema;
}
return null;