diff --git a/core/Application.php b/core/Application.php index 34932cab18399..8775b9cf88be4 100644 --- a/core/Application.php +++ b/core/Application.php @@ -218,6 +218,13 @@ function (GenericEvent $event) use ($container) { $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 a4379ffacc3be..c31acdb122537 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -435,6 +435,22 @@ private function addCoreIndexes(OutputInterface $output, bool $dryRun): void { } } + $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 76a3ae8c73c1e..6a3f5ad2faf9b 100644 --- a/core/Migrations/Version24000Date20220202150027.php +++ b/core/Migrations/Version24000Date20220202150027.php @@ -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;