From 957b8b20f96b8752b66d0f5906725b2813cfa3dd Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 13 Apr 2023 17:19:26 +0200 Subject: [PATCH] add new index in repair step instead of on-migrate Signed-off-by: Robin Appelman --- core/Application.php | 3 +++ core/Command/Db/AddMissingIndices.php | 8 ++++++++ core/Migrations/Version27000Date20220613163520.php | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/Application.php b/core/Application.php index 4ebbada95e666..2e35461015472 100644 --- a/core/Application.php +++ b/core/Application.php @@ -239,6 +239,9 @@ function (GenericEvent $event) use ($container) { if (!$table->hasIndex('mounts_class_index')) { $subject->addHintForMissingSubject($table->getName(), 'mounts_class_index'); } + if (!$table->hasIndex('mounts_user_root_path_index')) { + $subject->addHintForMissingSubject($table->getName(), 'mounts_user_root_path_index'); + } } } ); diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index e22d0fddeca34..b317f44b49930 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -465,6 +465,14 @@ private function addCoreIndexes(OutputInterface $output, bool $dryRun): void { $updated = true; $output->writeln('oc_mounts table updated successfully.'); } + if (!$table->hasIndex('mounts_user_root_path_index')) { + $output->writeln('Adding mounts_user_root_path_index index to the oc_mounts table, this can take some time...'); + + $table->addIndex(['user_id', 'root_id', 'mount_point'], 'mounts_user_root_path_index', [], ['lengths' => [null, null, 128]]); + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('oc_mounts table updated successfully.'); + } } if (!$updated) { diff --git a/core/Migrations/Version27000Date20220613163520.php b/core/Migrations/Version27000Date20220613163520.php index 5f327e69c964a..4217f3b3270aa 100644 --- a/core/Migrations/Version27000Date20220613163520.php +++ b/core/Migrations/Version27000Date20220613163520.php @@ -43,7 +43,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt $table = $schema->getTable('mounts'); if ($table->hasIndex('mounts_user_root_index')) { $table->dropIndex('mounts_user_root_index'); - $table->addIndex(['user_id', 'root_id', 'mount_point'], 'mounts_user_root_path_index', [], ['lengths' => [null, null, 128]]); + // new index gets added with "add missing indexes" } return $schema;