Only add index if does not exist yet

Signed-off-by: Julius Härtl <jus@bitgrid.net>
pull/975/head
Julius Härtl 2020-08-17 08:00:08 +02:00
rodzic db2b8912bc
commit 71918f1a0e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4C614C6ED2CDE6DF
2 zmienionych plików z 9 dodań i 8 usunięć

Wyświetl plik

@ -1056,7 +1056,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep {
); );
$table->setPrimaryKey(['id']); $table->setPrimaryKey(['id']);
$table->addIndex(['chunk'], 'chunk'); $table->addIndex(['chunk'], 'chunk_act');
$table->addUniqueIndex(['stream_id_prim', 'actor_id_prim'], 'sa'); $table->addUniqueIndex(['stream_id_prim', 'actor_id_prim'], 'sa');
} }
@ -1111,7 +1111,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep {
] ]
); );
$table->addIndex(['chunk'], 'chunk'); $table->addIndex(['chunk'], 'chunk_dest');
$table->addUniqueIndex(['stream_id', 'actor_id', 'type'], 'sat'); $table->addUniqueIndex(['stream_id', 'actor_id', 'type'], 'sat');
$table->addIndex(['type', 'subtype'], 'ts'); $table->addIndex(['type', 'subtype'], 'ts');
} }

Wyświetl plik

@ -73,9 +73,9 @@ class Version0003Date20200730213528 extends SimpleMigrationStep {
/** @var ISchemaWrapper $schema */ /** @var ISchemaWrapper $schema */
$schema = $schemaClosure(); $schema = $schemaClosure();
$this->addChunkToTable($schema, 'social_3_stream'); $this->addChunkToTable($schema, 'social_3_stream', '');
$this->addChunkToTable($schema, 'social_3_stream_act'); $this->addChunkToTable($schema, 'social_3_stream_act', '_act');
$this->addChunkToTable($schema, 'social_3_stream_dest'); $this->addChunkToTable($schema, 'social_3_stream_dest', '_dest');
return $schema; return $schema;
} }
@ -87,7 +87,7 @@ class Version0003Date20200730213528 extends SimpleMigrationStep {
* *
* @throws SchemaException * @throws SchemaException
*/ */
private function addChunkToTable(ISchemaWrapper $schema, string $tableName) { private function addChunkToTable(ISchemaWrapper $schema, string $tableName, string $indexName) {
if (!$schema->hasTable($tableName)) { if (!$schema->hasTable($tableName)) {
return; return;
} }
@ -105,8 +105,9 @@ class Version0003Date20200730213528 extends SimpleMigrationStep {
'unsigned' => true 'unsigned' => true
] ]
); );
if (!$table->hasIndex('chunk' . $indexName)) {
$table->addIndex(['chunk'], 'chunk'); $table->addIndex(['chunk'], 'chunk' . $indexName);
}
} }