diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index 4c86a8705db42..1a484dfc806c7 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -222,11 +222,15 @@ private function addCoreIndexes(OutputInterface $output) { $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'); + } } }