Browse Source

Merge pull request #13213 from nextcloud/enhancement/12943/index_twofactor_providers

Add twofactor_providers_uid index
tags/v16.0.0alpha1
Morris Jobke 5 years ago
parent
commit
c7399379c9
No account linked to committer's email address

+ 8
- 0
core/Application.php View File

$subject->addHintForMissingSubject($table->getName(), 'fs_mtime'); $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');
}
}
} }
); );
} }

+ 15
- 2
core/Command/Db/AddMissingIndices.php View File

} }


protected function execute(InputInterface $input, OutputInterface $output) { protected function execute(InputInterface $input, OutputInterface $output) {
$this->addShareTableIndicies($output);
$this->addCoreIndexes($output);


// Dispatch event so apps can also update indexes if needed // Dispatch event so apps can also update indexes if needed
$event = new GenericEvent($output); $event = new GenericEvent($output);
* @param OutputInterface $output * @param OutputInterface $output
* @throws \Doctrine\DBAL\Schema\SchemaException * @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>'); $output->writeln('<info>Check indices of the share table.</info>');


} }
} }


$output->writeln('<info>Check indices of the filecache table.</info>');
if ($schema->hasTable('filecache')) { if ($schema->hasTable('filecache')) {
$table = $schema->getTable('filecache'); $table = $schema->getTable('filecache');
if (!$table->hasIndex('fs_mtime')) { if (!$table->hasIndex('fs_mtime')) {
} }
} }


$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) { if (!$updated) {
$output->writeln('<info>Done.</info>'); $output->writeln('<info>Done.</info>');
} }

+ 1
- 0
core/Migrations/Version14000Date20180522074438.php View File

'length' => 1, 'length' => 1,
]); ]);
$table->setPrimaryKey(['provider_id', 'uid']); $table->setPrimaryKey(['provider_id', 'uid']);
$table->addIndex(['uid'], 'twofactor_providers_uid');
} }


return $schema; return $schema;

Loading…
Cancel
Save