Add twofactor_providers_uid index

Fixes #12943

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-12-21 13:02:25 +01:00
parent c2d75ddc4f
commit 16cc68a2fe
No known key found for this signature in database
GPG Key ID: F941078878347C0C
3 changed files with 24 additions and 2 deletions

View File

@ -85,6 +85,14 @@ class Application extends App {
$subject->addHintForMissingSubject($table->getName(), 'fs_mtime');
}
}
if ($schema->hasTable('twofactor_providers')) {
$table = $schema->getTable('twofactor_providers');
if (!$table->hasIndex('twofactor_providers_uid')) {
$subject->addHintForMissingSubject($table->getName(), 'twofactor_providers_uid');
}
}
}
);
}

View File

@ -61,7 +61,7 @@ class AddMissingIndices extends Command {
}
protected function execute(InputInterface $input, OutputInterface $output) {
$this->addShareTableIndicies($output);
$this->addCoreIndexes($output);
// Dispatch event so apps can also update indexes if needed
$event = new GenericEvent($output);
@ -74,7 +74,7 @@ class AddMissingIndices extends Command {
* @param OutputInterface $output
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
private function addShareTableIndicies(OutputInterface $output) {
private function addCoreIndexes(OutputInterface $output) {
$output->writeln('<info>Check indices of the share table.</info>');
@ -116,6 +116,7 @@ class AddMissingIndices extends Command {
}
}
$output->writeln('<info>Check indices of the filecache table.</info>');
if ($schema->hasTable('filecache')) {
$table = $schema->getTable('filecache');
if (!$table->hasIndex('fs_mtime')) {
@ -127,6 +128,18 @@ class AddMissingIndices extends Command {
}
}
$output->writeln('<info>Check indices of the twofactor_providers table.</info>');
if ($schema->hasTable('twofactor_providers')) {
$table = $schema->getTable('twofactor_providers');
if (!$table->hasIndex('twofactor_providers_uid')) {
$output->writeln('<info>Adding additional twofactor_providers_uid index to the twofactor_providers table, this can take some time...</info>');
$table->addIndex(['uid'], 'twofactor_providers_uid');
$this->connection->migrateToSchema($schema->getWrappedSchema());
$updated = true;
$output->writeln('<info>Twofactor_providers table updated successfully.</info>');
}
}
if (!$updated) {
$output->writeln('<info>Done.</info>');
}

View File

@ -55,6 +55,7 @@ class Version14000Date20180522074438 extends SimpleMigrationStep {
'length' => 1,
]);
$table->setPrimaryKey(['provider_id', 'uid']);
$table->addIndex(['uid'], 'twofactor_providers_uid');
}
return $schema;