From 7b6d85766d5f67eed718ad5c456e44a1afe78289 Mon Sep 17 00:00:00 2001 From: solocla Date: Thu, 23 Jul 2026 12:18:56 +0200 Subject: [PATCH] change migration --- ...723100916_drop_uniq_part_analysis_index.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/db/migrations/20260723100916_drop_uniq_part_analysis_index.php b/db/migrations/20260723100916_drop_uniq_part_analysis_index.php index f78d146..3927e7a 100644 --- a/db/migrations/20260723100916_drop_uniq_part_analysis_index.php +++ b/db/migrations/20260723100916_drop_uniq_part_analysis_index.php @@ -8,18 +8,22 @@ final class DropUniqPartAnalysisIndex extends AbstractMigration { public function up(): void { - $this->table('identification_parts_analyses') - ->removeIndexByName('uniq_part_analysis') - ->update(); + $table = $this->table('identification_parts_analyses'); + + if ($table->hasIndexByName('uniq_part_analysis')) { + $table->removeIndexByName('uniq_part_analysis')->update(); + } } public function down(): void { - $this->table('identification_parts_analyses') - ->addIndex(['part_id', 'analysis_recordkey'], [ + $table = $this->table('identification_parts_analyses'); + + if (!$table->hasIndexByName('uniq_part_analysis')) { + $table->addIndex(['part_id', 'analysis_recordkey'], [ 'unique' => true, 'name' => 'uniq_part_analysis', - ]) - ->update(); + ])->update(); + } } }