Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions core/Command/Db/AddMissingIndices.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,15 @@ private function addCoreIndexes(OutputInterface $output, bool $dryRun): void {
$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');
}
}
Comment on lines +266 to 270
Copy link
Contributor Author

@artonge artonge Feb 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@julius, looks like you wrote the code.

Can you tell me why we use a foreach instead of renaming the index directly? I feel like I am missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

Expand Down