From 2b27aa50d5986812ef370397e38565596d83d497 Mon Sep 17 00:00:00 2001 From: Thorsten Bus Date: Sun, 3 May 2026 22:20:01 +0200 Subject: [PATCH] feat(db)!: drop song_groups, introduce label_id on song_slides, add song_arrangement_labels (BREAKING) --- ..._05_03_100600_refactor_songs_to_labels.php | 38 +++++++++++++++++++ .../Migrations/SongsToLabelsRefactorTest.php | 21 ++++++++++ 2 files changed, 59 insertions(+) create mode 100644 database/migrations/2026_05_03_100600_refactor_songs_to_labels.php create mode 100644 tests/Feature/Migrations/SongsToLabelsRefactorTest.php diff --git a/database/migrations/2026_05_03_100600_refactor_songs_to_labels.php b/database/migrations/2026_05_03_100600_refactor_songs_to_labels.php new file mode 100644 index 0000000..29c5c20 --- /dev/null +++ b/database/migrations/2026_05_03_100600_refactor_songs_to_labels.php @@ -0,0 +1,38 @@ +dropUnique(['song_group_id', 'order']); + $table->dropIndex(['song_group_id']); + $table->dropForeign(['song_group_id']); + $table->dropColumn('song_group_id'); + }); + + Schema::table('song_slides', function (Blueprint $table) { + $table->foreignId('label_id')->nullable()->constrained('labels')->restrictOnDelete(); + }); + + Schema::dropIfExists('song_arrangement_groups'); + Schema::dropIfExists('song_groups'); + + Schema::create('song_arrangement_labels', function (Blueprint $table) { + $table->id(); + $table->foreignId('song_arrangement_id')->constrained()->cascadeOnDelete(); + $table->foreignId('label_id')->constrained('labels')->restrictOnDelete(); + $table->unsignedInteger('order'); + $table->timestamps(); + $table->index(['song_arrangement_id', 'order']); + }); + } + + public function down(): void + { + throw new \RuntimeException('Destructive migration: rollback not supported. Restore from backup.'); + } +}; diff --git a/tests/Feature/Migrations/SongsToLabelsRefactorTest.php b/tests/Feature/Migrations/SongsToLabelsRefactorTest.php new file mode 100644 index 0000000..78bcc7d --- /dev/null +++ b/tests/Feature/Migrations/SongsToLabelsRefactorTest.php @@ -0,0 +1,21 @@ +toBeTrue(); + expect(Schema::hasColumn('song_slides', 'song_group_id'))->toBeFalse(); +}); + +test('song_arrangement_groups table is dropped', function () { + expect(Schema::hasTable('song_arrangement_groups'))->toBeFalse(); +}); + +test('song_arrangement_labels table exists with expected columns', function () { + expect(Schema::hasTable('song_arrangement_labels'))->toBeTrue(); + expect(Schema::hasColumns('song_arrangement_labels', ['id', 'song_arrangement_id', 'label_id', 'order', 'created_at', 'updated_at']))->toBeTrue(); +}); + +test('song_groups table is dropped', function () { + expect(Schema::hasTable('song_groups'))->toBeFalse(); +});