diff options
Diffstat (limited to 'core/Command/Db/AddMissingIndices.php')
-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>'); } |