]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't create cards_abiduri it if already exists 31221/head
authorLouis Chemineau <louis@chmn.me>
Wed, 16 Feb 2022 17:42:14 +0000 (18:42 +0100)
committerLouis (Rebase PR Action) <artonge@users.noreply.github.com>
Thu, 24 Mar 2022 10:42:22 +0000 (10:42 +0000)
Signed-off-by: Louis Chemineau <louis@chmn.me>
core/Command/Db/AddMissingIndices.php

index f1dba2f4c319399e73723a8a19de007679c54177..a4379ffacc3bec3800e40b81a7df69d1b28a0d3f 100644 (file)
@@ -258,11 +258,15 @@ class AddMissingIndices extends Command {
                        $table = $schema->getTable('cards');
 
                        if ($table->hasIndex('addressbookid_uri_index')) {
-                               $output->writeln('<info>Renaming addressbookid_uri_index index to  to the cards table, this can take some time...</info>');
-
-                               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('<info>Renaming addressbookid_uri_index index to cards_abiduri in the cards table, this can take some time...</info>');
+
+                                       foreach ($table->getIndexes() as $index) {
+                                               if ($index->getColumns() === ['addressbookid', 'uri']) {
+                                                       $table->renameIndex('addressbookid_uri_index', 'cards_abiduri');
+                                               }
                                        }
                                }