diff options
author | Louis Chemineau <louis@chmn.me> | 2022-02-16 20:42:14 +0300 |
---|---|---|
committer | Louis (Rebase PR Action) <artonge@users.noreply.github.com> | 2022-03-24 13:42:22 +0300 |
commit | 970fb7ce655245f653869ad52291f8d22d78e4d4 (patch) | |
tree | 43aa1c2e52ac39d0e9307f8c9f847e17fc50bcb2 /core/Command/Db | |
parent | c9ea2363b1e50748b7c85f1e14b036c3d92cc31a (diff) |
Don't create cards_abiduri it if already exists
Signed-off-by: Louis Chemineau <louis@chmn.me>
Diffstat (limited to 'core/Command/Db')
-rw-r--r-- | core/Command/Db/AddMissingIndices.php | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index f1dba2f4c31..a4379ffacc3 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -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'); + } } } |