From 767e22eac8b75a44b334050c6bb13e64a24e4f15 Mon Sep 17 00:00:00 2001 From: Thorsten Bus Date: Sun, 3 May 2026 22:10:35 +0200 Subject: [PATCH] feat(db): create labels table for global slide labels Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- .../2026_05_03_100100_create_labels_table.php | 24 +++++++++++++++++++ tests/Feature/Migrations/LabelsTableTest.php | 22 +++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 database/migrations/2026_05_03_100100_create_labels_table.php create mode 100644 tests/Feature/Migrations/LabelsTableTest.php diff --git a/database/migrations/2026_05_03_100100_create_labels_table.php b/database/migrations/2026_05_03_100100_create_labels_table.php new file mode 100644 index 0000000..1eccceb --- /dev/null +++ b/database/migrations/2026_05_03_100100_create_labels_table.php @@ -0,0 +1,24 @@ +id(); + $table->string('name')->unique(); + $table->string('color', 7)->nullable(); + $table->timestamp('hidden_at')->nullable(); + $table->timestamp('last_imported_at')->nullable(); + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('labels'); + } +}; diff --git a/tests/Feature/Migrations/LabelsTableTest.php b/tests/Feature/Migrations/LabelsTableTest.php new file mode 100644 index 0000000..d106a9e --- /dev/null +++ b/tests/Feature/Migrations/LabelsTableTest.php @@ -0,0 +1,22 @@ +toBeTrue(); + expect(Schema::hasColumns('labels', ['id', 'name', 'color', 'hidden_at', 'last_imported_at', 'created_at', 'updated_at']))->toBeTrue(); +}); + +test('labels table enforces unique name', function () { + DB::table('labels')->insert(['name' => 'Vers 1', 'color' => '#FF0080', 'created_at' => now(), 'updated_at' => now()]); + + expect(fn () => DB::table('labels')->insert(['name' => 'Vers 1', 'color' => '#000000', 'created_at' => now(), 'updated_at' => now()])) + ->toThrow(\Exception::class); +}); + +test('labels table allows nullable color', function () { + DB::table('labels')->insert(['name' => 'TestLabel', 'color' => null, 'created_at' => now(), 'updated_at' => now()]); + + expect(DB::table('labels')->where('name', 'TestLabel')->value('color'))->toBeNull(); +});