From 71918f1a0eaffab2e58379573f16b22e782cc17d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 17 Aug 2020 08:00:08 +0200 Subject: Only add index if does not exist yet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Migration/Version0003Date20200611000001.php | 4 ++-- lib/Migration/Version0003Date20200730213528.php | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/Migration/Version0003Date20200611000001.php b/lib/Migration/Version0003Date20200611000001.php index eed82542..51274e52 100644 --- a/lib/Migration/Version0003Date20200611000001.php +++ b/lib/Migration/Version0003Date20200611000001.php @@ -1056,7 +1056,7 @@ class Version0003Date20200611000001 extends SimpleMigrationStep { ); $table->setPrimaryKey(['id']); - $table->addIndex(['chunk'], 'chunk'); + $table->addIndex(['chunk'], 'chunk_act'); $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->addIndex(['type', 'subtype'], 'ts'); } diff --git a/lib/Migration/Version0003Date20200730213528.php b/lib/Migration/Version0003Date20200730213528.php index cf7fed6d..e0e3a5a8 100644 --- a/lib/Migration/Version0003Date20200730213528.php +++ b/lib/Migration/Version0003Date20200730213528.php @@ -73,9 +73,9 @@ class Version0003Date20200730213528 extends SimpleMigrationStep { /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); - $this->addChunkToTable($schema, 'social_3_stream'); - $this->addChunkToTable($schema, 'social_3_stream_act'); - $this->addChunkToTable($schema, 'social_3_stream_dest'); + $this->addChunkToTable($schema, 'social_3_stream', ''); + $this->addChunkToTable($schema, 'social_3_stream_act', '_act'); + $this->addChunkToTable($schema, 'social_3_stream_dest', '_dest'); return $schema; } @@ -87,7 +87,7 @@ class Version0003Date20200730213528 extends SimpleMigrationStep { * * @throws SchemaException */ - private function addChunkToTable(ISchemaWrapper $schema, string $tableName) { + private function addChunkToTable(ISchemaWrapper $schema, string $tableName, string $indexName) { if (!$schema->hasTable($tableName)) { return; } @@ -105,8 +105,9 @@ class Version0003Date20200730213528 extends SimpleMigrationStep { 'unsigned' => true ] ); - - $table->addIndex(['chunk'], 'chunk'); + if (!$table->hasIndex('chunk' . $indexName)) { + $table->addIndex(['chunk'], 'chunk' . $indexName); + } } -- cgit v1.2.3