feat(db): create labels table for global slide labels

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
Thorsten Bus 2026-05-03 22:10:35 +02:00
parent e489a984eb
commit 767e22eac8
2 changed files with 46 additions and 0 deletions

View file

@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
public function up(): void
{
Schema::create('labels', function (Blueprint $table) {
$table->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');
}
};

View file

@ -0,0 +1,22 @@
<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
test('labels table has expected columns', function () {
expect(Schema::hasTable('labels'))->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();
});