diff --git a/apps/dav/lib/Migration/Version1004Date20170924124212.php b/apps/dav/lib/Migration/Version1004Date20170924124212.php index e3f509b2a71df..7a87f6d2b0444 100644 --- a/apps/dav/lib/Migration/Version1004Date20170924124212.php +++ b/apps/dav/lib/Migration/Version1004Date20170924124212.php @@ -40,10 +40,10 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op $schema = $schemaClosure(); $table = $schema->getTable('cards'); - $table->addIndex(['addressbookid']); + $table->addIndex(['addressbookid'], 'cards_abid'); $table = $schema->getTable('cards_properties'); - $table->addIndex(['addressbookid']); + $table->addIndex(['addressbookid'], 'cards_prop_abid'); return $schema; } diff --git a/core/Application.php b/core/Application.php index 94990df935686..5ba07e2cb481c 100644 --- a/core/Application.php +++ b/core/Application.php @@ -93,6 +93,44 @@ function(GenericEvent $event) use ($container) { $subject->addHintForMissingSubject($table->getName(), 'twofactor_providers_uid'); } } + + if ($schema->hasTable('login_flow_v2')) { + $table = $schema->getTable('login_flow_v2'); + + if (!$table->hasIndex('poll_token')) { + $subject->addHintForMissingSubject($table->getName(), 'poll_token'); + } + if (!$table->hasIndex('login_token')) { + $subject->addHintForMissingSubject($table->getName(), 'login_token'); + } + if (!$table->hasIndex('timestamp')) { + $subject->addHintForMissingSubject($table->getName(), 'timestamp'); + } + } + + if ($schema->hasTable('whats_new')) { + $table = $schema->getTable('whats_new'); + + if (!$table->hasIndex('version')) { + $subject->addHintForMissingSubject($table->getName(), 'version'); + } + } + + if ($schema->hasTable('cards')) { + $table = $schema->getTable('cards'); + + if (!$table->hasIndex('cards_abid')) { + $subject->addHintForMissingSubject($table->getName(), 'cards_abid'); + } + } + + if ($schema->hasTable('cards_properties')) { + $table = $schema->getTable('cards_properties'); + + if (!$table->hasIndex('cards_prop_abid')) { + $subject->addHintForMissingSubject($table->getName(), 'cards_prop_abid'); + } + } } ); } diff --git a/core/Command/Db/AddMissingIndices.php b/core/Command/Db/AddMissingIndices.php index 3bc66988529e9..0bb6658e85e13 100644 --- a/core/Command/Db/AddMissingIndices.php +++ b/core/Command/Db/AddMissingIndices.php @@ -140,6 +140,87 @@ private function addCoreIndexes(OutputInterface $output) { } } + $output->writeln('Check indices of the login_flow_v2 table.'); + if ($schema->hasTable('login_flow_v2')) { + $table = $schema->getTable('login_flow_v2'); + if (!$table->hasIndex('poll_token')) { + $output->writeln('Adding additional indeces to the login_flow_v2 table, this can take some time...'); + + 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('login_flow_v2 table updated successfully.'); + } + } + + $output->writeln('Check indices of the whats_new table.'); + if ($schema->hasTable('whats_new')) { + $table = $schema->getTable('whats_new'); + if (!$table->hasIndex('version')) { + $output->writeln('Adding version index to the whats_new table, this can take some time...'); + + 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('whats_new table updated successfully.'); + } + } + + $output->writeln('Check indices of the cards table.'); + if ($schema->hasTable('cards')) { + $table = $schema->getTable('cards'); + if (!$table->hasIndex('cards_abid')) { + $output->writeln('Adding cards_abid index to the cards table, this can take some time...'); + + foreach ($table->getIndexes() as $index) { + if ($index->getColumns() === ['addressbookid']) { + $table->dropIndex($index->getName()); + } + } + + $table->addIndex(['addressbookid'], 'cards_abid'); + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('cards table updated successfully.'); + } + } + + $output->writeln('Check indices of the cards_properties table.'); + if ($schema->hasTable('cards_properties')) { + $table = $schema->getTable('cards_properties'); + if (!$table->hasIndex('cards_prop_abid')) { + $output->writeln('Adding cards_prop_abid index to the cards_properties table, this can take some time...'); + + foreach ($table->getIndexes() as $index) { + if ($index->getColumns() === ['addressbookid']) { + $table->dropIndex($index->getName()); + } + } + + $table->addIndex(['addressbookid'], 'cards_prop_abid'); + $this->connection->migrateToSchema($schema->getWrappedSchema()); + $updated = true; + $output->writeln('cards_properties table updated successfully.'); + } + } + if (!$updated) { $output->writeln('Done.'); } diff --git a/core/Migrations/Version14000Date20180626223656.php b/core/Migrations/Version14000Date20180626223656.php index fb7a6c647bcb2..17b3674d27231 100644 --- a/core/Migrations/Version14000Date20180626223656.php +++ b/core/Migrations/Version14000Date20180626223656.php @@ -60,7 +60,7 @@ public function changeSchema(\OCP\Migration\IOutput $output, \Closure $schemaClo 'default' => '', ]); $table->setPrimaryKey(['id']); - $table->addUniqueIndex(['version']); + $table->addUniqueIndex(['version'], 'version'); $table->addIndex(['version', 'etag'], 'version_etag_idx'); } diff --git a/core/Migrations/Version16000Date20190212081545.php b/core/Migrations/Version16000Date20190212081545.php index 6f6902bf17743..dcb2722222a69 100644 --- a/core/Migrations/Version16000Date20190212081545.php +++ b/core/Migrations/Version16000Date20190212081545.php @@ -92,9 +92,9 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt 'length' => 1024, ]); $table->setPrimaryKey(['id']); - $table->addUniqueIndex(['poll_token']); - $table->addUniqueIndex(['login_token']); - $table->addIndex(['timestamp']); + $table->addUniqueIndex(['poll_token'], 'poll_token'); + $table->addUniqueIndex(['login_token'], 'login_token'); + $table->addIndex(['timestamp'], 'timestamp'); return $schema; }