From 33a0aa699472d43c64f78b9adc6bbf3ad6f49285 Mon Sep 17 00:00:00 2001 From: Johannes Merkel Date: Tue, 19 Mar 2024 11:44:00 +0100 Subject: [PATCH] fix(settings): show warning for indexToReplace as part of missing indices Signed-off-by: Johannes Merkel --- .../lib/SetupChecks/DatabaseHasMissingIndices.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/settings/lib/SetupChecks/DatabaseHasMissingIndices.php b/apps/settings/lib/SetupChecks/DatabaseHasMissingIndices.php index ccf6bbb52d0ec..bd33f513b56b6 100644 --- a/apps/settings/lib/SetupChecks/DatabaseHasMissingIndices.php +++ b/apps/settings/lib/SetupChecks/DatabaseHasMissingIndices.php @@ -56,6 +56,7 @@ private function getMissingIndices(): array { $event = new AddMissingIndicesEvent(); $this->dispatcher->dispatchTyped($event); $missingIndices = $event->getMissingIndices(); + $indicesToReplace = $event->getIndicesToReplace(); if (!empty($missingIndices)) { $schema = new SchemaWrapper($this->connection); @@ -69,6 +70,18 @@ private function getMissingIndices(): array { } } + if (!empty($indicesToReplace)) { + $schema = new SchemaWrapper($this->connection); + foreach ($indicesToReplace as $indexToReplace) { + if ($schema->hasTable($indexToReplace['tableName'])) { + $table = $schema->getTable($indexToReplace['tableName']); + if (!$table->hasIndex($indexToReplace['newIndexName'])) { + $indexInfo->addHintForMissingIndex($indexToReplace['tableName'], $indexToReplace['newIndexName']); + } + } + } + } + return $indexInfo->getListOfMissingIndices(); }