diff options
author | Joas Schilling <coding@schilljs.com> | 2019-03-27 11:42:33 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-03-27 13:32:59 +0100 |
commit | 274658629d2f7e72de123a8763f2578f79cb3376 (patch) | |
tree | 4af81fdbc7c3440f9657b24fe46037a23f741a46 /core/Command | |
parent | 86594e8c18123db6696f4cedfc0578d036ad5dd6 (diff) | |
download | nextcloud-server-274658629d2f7e72de123a8763f2578f79cb3376.tar.gz nextcloud-server-274658629d2f7e72de123a8763f2578f79cb3376.zip |
Make sure all tables have named indexes
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core/Command')
-rw-r--r-- | core/Command/Db/AddMissingIndices.php | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index 3bc66988529..9df76f67b7b 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -140,6 +140,87 @@ class AddMissingIndices extends Command { } } + $output->writeln('<info>Check indices of the login_flow_v2 table.</info>'); + if ($schema->hasTable('login_flow_v2')) { + $table = $schema->getTable('login_flow_v2'); + if (!$table->hasIndex('poll_token')) { + $output->writeln('<info>Adding additional indeces to the login_flow_v2 table, this can take some time...</info>'); + + foreach ($table->getIndexes() as $index) { + $columns = $index->getColumns(); + if ($columns === ['poll_token'] || + $columns === ['login_token'] || + $columns === ['timestamp']) { + $table->dropIndex($index->getName()); + } + } + + $table->addUniqueIndex(['poll_token'], 'poll_token'); + $table->addUniqueIndex(['login_token'], 'login_token'); + $table->addIndex(['timestamp'], 'timestamp'); + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('<info>login_flow_v2 table updated successfully.</info>'); + } + } + + $output->writeln('<info>Check indices of the whats_new table.</info>'); + if ($schema->hasTable('whats_new')) { + $table = $schema->getTable('whats_new'); + if (!$table->hasIndex('version')) { + $output->writeln('<info>Adding version index to the whats_new table, this can take some time...</info>'); + + foreach ($table->getIndexes() as $index) { + if ($index->getColumns() === ['version']) { + $table->dropIndex($index->getName()); + } + } + + $table->addUniqueIndex(['version'], 'version'); + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('<info>whats_new table updated successfully.</info>'); + } + } + + $output->writeln('<info>Check indices of the cards table.</info>'); + if ($schema->hasTable('cards')) { + $table = $schema->getTable('cards'); + if (!$table->hasIndex('addressbookid')) { + $output->writeln('<info>Adding addressbookid index to the cards table, this can take some time...</info>'); + + foreach ($table->getIndexes() as $index) { + if ($index->getColumns() === ['addressbookid']) { + $table->dropIndex($index->getName()); + } + } + + $table->addIndex(['addressbookid'], 'addressbookid'); + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('<info>cards table updated successfully.</info>'); + } + } + + $output->writeln('<info>Check indices of the cards_properties table.</info>'); + if ($schema->hasTable('cards_properties')) { + $table = $schema->getTable('cards_properties'); + if (!$table->hasIndex('addressbookid')) { + $output->writeln('<info>Adding addressbookid index to the cards_properties table, this can take some time...</info>'); + + foreach ($table->getIndexes() as $index) { + if ($index->getColumns() === ['addressbookid']) { + $table->dropIndex($index->getName()); + } + } + + $table->addIndex(['addressbookid'], 'addressbookid'); + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('<info>cards_properties table updated successfully.</info>'); + } + } + if (!$updated) { $output->writeln('<info>Done.</info>'); } |