Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/dav/lib/Migration/Version1004Date20170924124212.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
38 changes: 38 additions & 0 deletions core/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
}
);
}
Expand Down
81 changes: 81 additions & 0 deletions core/Command/Db/AddMissingIndices.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,87 @@ private function addCoreIndexes(OutputInterface $output) {
}
}

$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('cards_abid')) {
$output->writeln('<info>Adding cards_abid 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'], 'cards_abid');
$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('cards_prop_abid')) {
$output->writeln('<info>Adding cards_prop_abid 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'], 'cards_prop_abid');
$this->connection->migrateToSchema($schema->getWrappedSchema());
$updated = true;
$output->writeln('<info>cards_properties table updated successfully.</info>');
}
}

if (!$updated) {
$output->writeln('<info>Done.</info>');
}
Expand Down
2 changes: 1 addition & 1 deletion core/Migrations/Version14000Date20180626223656.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
6 changes: 3 additions & 3 deletions core/Migrations/Version16000Date20190212081545.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down