diff options
author | Julius Härtl <jus@bitgrid.net> | 2020-11-27 13:24:33 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2020-12-09 12:13:34 +0100 |
commit | c77e259cfe102f2ca9643eab9bbb6ee72cd3ea58 (patch) | |
tree | 9ca161e30c5ee76aa84c142fe31ee445c32ffc01 /core/Command/Db | |
parent | 3c9218ab26ae943e3b072ad32c5d2bf2e77ac285 (diff) | |
download | nextcloud-server-c77e259cfe102f2ca9643eab9bbb6ee72cd3ea58.tar.gz nextcloud-server-c77e259cfe102f2ca9643eab9bbb6ee72cd3ea58.zip |
Add missing index on oc_cards and rename if it previously existed
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'core/Command/Db')
-rw-r--r-- | core/Command/Db/AddMissingIndices.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index d06f27e8449..49fc16b079a 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -200,8 +200,23 @@ class AddMissingIndices extends Command { } $output->writeln('<info>Check indices of the cards table.</info>'); + $cardsUpdated = false; if ($schema->hasTable('cards')) { $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'); + } + } + + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $cardsUpdated = true; + } + if (!$table->hasIndex('cards_abid')) { $output->writeln('<info>Adding cards_abid index to the cards table, this can take some time...</info>'); @@ -213,6 +228,24 @@ class AddMissingIndices extends Command { $table->addIndex(['addressbookid'], 'cards_abid'); $this->connection->migrateToSchema($schema->getWrappedSchema()); + $cardsUpdated = true; + } + + if (!$table->hasIndex('cards_abiduri')) { + $output->writeln('<info>Adding cards_abiduri index to the cards table, this can take some time...</info>'); + + foreach ($table->getIndexes() as $index) { + if ($index->getColumns() === ['addressbookid', 'uri']) { + $table->dropIndex($index->getName()); + } + } + + $table->addIndex(['addressbookid', 'uri'], 'cards_abiduri'); + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $cardsUpdated = true; + } + + if ($cardsUpdated) { $updated = true; $output->writeln('<info>cards table updated successfully.</info>'); } |