From 67af99e14e548a0805a6cd8dff8b2edef777b94c Mon Sep 17 00:00:00 2001 From: Marcel Klehr Date: Fri, 29 Jul 2022 14:43:26 +0200 Subject: [PATCH] DB mounts table: Add index for mount_provider_class Signed-off-by: Marcel Klehr --- core/Application.php | 7 +++++++ core/Command/Db/AddMissingIndices.php | 16 ++++++++++++++++ .../Version24000Date20220202150027.php | 1 + 3 files changed, 24 insertions(+) diff --git a/core/Application.php b/core/Application.php index 34932cab183..8775b9cf88b 100644 --- a/core/Application.php +++ b/core/Application.php @@ -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'); + } + } } ); diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index a4379ffacc3..c31acdb1225 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -435,6 +435,22 @@ class AddMissingIndices extends Command { } } + $output->writeln('Check indices of the oc_mounts table.'); + if ($schema->hasTable('mounts')) { + $table = $schema->getTable('mounts'); + if (!$table->hasIndex('mounts_class_index')) { + $output->writeln('Adding mounts_class_index index to the oc_mounts table, this can take some time...'); + + $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('oc_mounts table updated successfully.'); + } + } + if (!$updated) { $output->writeln('Done.'); } diff --git a/core/Migrations/Version24000Date20220202150027.php b/core/Migrations/Version24000Date20220202150027.php index 76a3ae8c73c..6a3f5ad2faf 100644 --- a/core/Migrations/Version24000Date20220202150027.php +++ b/core/Migrations/Version24000Date20220202150027.php @@ -30,6 +30,7 @@ class Version24000Date20220202150027 extends SimpleMigrationStep { 'notnull' => false, 'length' => 128, ]); + $table->addIndex(['mount_provider_class'], 'mounts_class_index'); return $schema; } return null; -- 2.39.5