Deduplicate index names

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2019-03-27 12:11:35 +01:00 committed by Roeland Jago Douma
parent 274658629d
commit 592093079f
No known key found for this signature in database
GPG Key ID: F941078878347C0C
3 changed files with 12 additions and 12 deletions

View File

@ -40,10 +40,10 @@ class Version1004Date20170924124212 extends SimpleMigrationStep {
$schema = $schemaClosure(); $schema = $schemaClosure();
$table = $schema->getTable('cards'); $table = $schema->getTable('cards');
$table->addIndex(['addressbookid'], 'addressbookid'); $table->addIndex(['addressbookid'], 'cards_abid');
$table = $schema->getTable('cards_properties'); $table = $schema->getTable('cards_properties');
$table->addIndex(['addressbookid'], 'addressbookid'); $table->addIndex(['addressbookid'], 'cards_prop_abid');
return $schema; return $schema;
} }

View File

@ -119,16 +119,16 @@ class Application extends App {
if ($schema->hasTable('cards')) { if ($schema->hasTable('cards')) {
$table = $schema->getTable('cards'); $table = $schema->getTable('cards');
if (!$table->hasIndex('addressbookid')) { if (!$table->hasIndex('cards_abid')) {
$subject->addHintForMissingSubject($table->getName(), 'addressbookid'); $subject->addHintForMissingSubject($table->getName(), 'cards_abid');
} }
} }
if ($schema->hasTable('cards_properties')) { if ($schema->hasTable('cards_properties')) {
$table = $schema->getTable('cards_properties'); $table = $schema->getTable('cards_properties');
if (!$table->hasIndex('addressbookid')) { if (!$table->hasIndex('cards_prop_abid')) {
$subject->addHintForMissingSubject($table->getName(), 'addressbookid'); $subject->addHintForMissingSubject($table->getName(), 'cards_prop_abid');
} }
} }
} }

View File

@ -186,8 +186,8 @@ class AddMissingIndices extends Command {
$output->writeln('<info>Check indices of the cards table.</info>'); $output->writeln('<info>Check indices of the cards table.</info>');
if ($schema->hasTable('cards')) { if ($schema->hasTable('cards')) {
$table = $schema->getTable('cards'); $table = $schema->getTable('cards');
if (!$table->hasIndex('addressbookid')) { if (!$table->hasIndex('cards_abid')) {
$output->writeln('<info>Adding addressbookid index to the cards table, this can take some time...</info>'); $output->writeln('<info>Adding cards_abid index to the cards table, this can take some time...</info>');
foreach ($table->getIndexes() as $index) { foreach ($table->getIndexes() as $index) {
if ($index->getColumns() === ['addressbookid']) { if ($index->getColumns() === ['addressbookid']) {
@ -195,7 +195,7 @@ class AddMissingIndices extends Command {
} }
} }
$table->addIndex(['addressbookid'], 'addressbookid'); $table->addIndex(['addressbookid'], 'cards_abid');
$this->connection->migrateToSchema($schema->getWrappedSchema()); $this->connection->migrateToSchema($schema->getWrappedSchema());
$updated = true; $updated = true;
$output->writeln('<info>cards table updated successfully.</info>'); $output->writeln('<info>cards table updated successfully.</info>');
@ -205,8 +205,8 @@ class AddMissingIndices extends Command {
$output->writeln('<info>Check indices of the cards_properties table.</info>'); $output->writeln('<info>Check indices of the cards_properties table.</info>');
if ($schema->hasTable('cards_properties')) { if ($schema->hasTable('cards_properties')) {
$table = $schema->getTable('cards_properties'); $table = $schema->getTable('cards_properties');
if (!$table->hasIndex('addressbookid')) { if (!$table->hasIndex('cards_prop_abid')) {
$output->writeln('<info>Adding addressbookid index to the cards_properties table, this can take some time...</info>'); $output->writeln('<info>Adding cards_prop_abid index to the cards_properties table, this can take some time...</info>');
foreach ($table->getIndexes() as $index) { foreach ($table->getIndexes() as $index) {
if ($index->getColumns() === ['addressbookid']) { if ($index->getColumns() === ['addressbookid']) {
@ -214,7 +214,7 @@ class AddMissingIndices extends Command {
} }
} }
$table->addIndex(['addressbookid'], 'addressbookid'); $table->addIndex(['addressbookid'], 'cards_prop_abid');
$this->connection->migrateToSchema($schema->getWrappedSchema()); $this->connection->migrateToSchema($schema->getWrappedSchema());
$updated = true; $updated = true;
$output->writeln('<info>cards_properties table updated successfully.</info>'); $output->writeln('<info>cards_properties table updated successfully.</info>');