From ed3e37f3c1fbc88c0067149dca5b729badd5861a Mon Sep 17 00:00:00 2001 From: Louis Chemineau Date: Wed, 16 Feb 2022 18:42:14 +0100 Subject: Don't create cards_abiduri it if already exists Signed-off-by: Louis Chemineau --- core/Command/Db/AddMissingIndices.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'core') diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index 4c86a8705db..1a484dfc806 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -222,11 +222,15 @@ class AddMissingIndices extends Command { $table = $schema->getTable('cards'); if ($table->hasIndex('addressbookid_uri_index')) { - $output->writeln('Renaming addressbookid_uri_index index to to the cards table, this can take some time...'); - - foreach ($table->getIndexes() as $index) { - if ($index->getColumns() === ['addressbookid', 'uri']) { - $table->renameIndex('addressbookid_uri_index', 'cards_abiduri'); + if ($table->hasIndex('cards_abiduri')) { + $table->dropIndex('addressbookid_uri_index'); + } else { + $output->writeln('Renaming addressbookid_uri_index index to cards_abiduri in the cards table, this can take some time...'); + + foreach ($table->getIndexes() as $index) { + if ($index->getColumns() === ['addressbookid', 'uri']) { + $table->renameIndex('addressbookid_uri_index', 'cards_abiduri'); + } } } -- cgit v1.2.3