feat(timetable): RFC v0.2 §5.3 migrations — artists, engagements, stages, performances, advancing

Ten migrations creating the artist + timetable foundation per
RFC-TIMETABLE v0.2 Session 1:

- genres (org-scoped vocab, D24)
- artists (master, org-scoped — slug-unique per org)
- companies.handles_buma column (D26 — BUMA flag on agencies)
- artist_contacts (master-scoped contacts)
- stages (event-scoped, sort_order per D23)
- stage_days (pure pivot stage↔event, integer PK)
- artist_engagements (per-event booking, denorm organisation_id, D9/D10)
- performances (engagement-scoped, nullable stage_id = wachtrij, D13/D14)
- advance_sections (engagement-scoped — was artist-scoped in pre-v0.2 plan)
- advance_submissions (audit-immutable per section)

Schema dump regenerated against crewli_test (migrate → schema:dump),
verified migrate:fresh round-trips cleanly with the dump as fast-path.

Closes part of ARCH-09.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-08 17:55:34 +02:00
parent c31f2ba784
commit 0c03c449c3
11 changed files with 1109 additions and 583 deletions

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
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('genres', function (Blueprint $table) {
$table->ulid('id')->primary();
$table->foreignUlid('organisation_id')->constrained()->cascadeOnDelete();
$table->string('name', 40);
$table->string('color', 7)->nullable();
$table->integer('sort_order')->default(0);
$table->boolean('is_active')->default(true);
$table->timestamps();
$table->unique(['organisation_id', 'name']);
});
}
public function down(): void
{
Schema::dropIfExists('genres');
}
};

View File

@@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
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('artists', function (Blueprint $table) {
$table->ulid('id')->primary();
$table->foreignUlid('organisation_id')->constrained()->cascadeOnDelete();
$table->string('name', 120);
$table->string('slug', 120);
$table->foreignUlid('default_genre_id')->nullable()->constrained('genres')->nullOnDelete();
$table->integer('default_draw')->nullable();
$table->tinyInteger('star_rating')->nullable();
$table->string('home_base_country', 2)->nullable();
$table->foreignUlid('agent_company_id')->nullable()->constrained('companies')->nullOnDelete();
$table->text('notes')->nullable();
$table->timestamps();
$table->softDeletes();
$table->unique(['organisation_id', 'slug']);
$table->index(['organisation_id', 'name']);
$table->index('default_genre_id');
$table->index('agent_company_id');
});
}
public function down(): void
{
Schema::dropIfExists('artists');
}
};

View File

@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
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::table('companies', function (Blueprint $table) {
$table->boolean('handles_buma')->default(false)->after('type');
});
}
public function down(): void
{
Schema::table('companies', function (Blueprint $table) {
$table->dropColumn('handles_buma');
});
}
};

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
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('artist_contacts', function (Blueprint $table) {
$table->ulid('id')->primary();
$table->foreignUlid('artist_id')->constrained()->cascadeOnDelete();
$table->string('name', 120);
$table->string('email')->nullable();
$table->string('phone')->nullable();
$table->string('role', 60);
$table->boolean('is_primary')->default(false);
$table->boolean('receives_briefing')->default(false);
$table->boolean('receives_infosheet')->default(false);
$table->timestamps();
$table->index(['artist_id', 'role']);
});
}
public function down(): void
{
Schema::dropIfExists('artist_contacts');
}
};

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
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('stages', function (Blueprint $table) {
$table->ulid('id')->primary();
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
$table->string('name', 120);
$table->string('color', 7);
$table->integer('capacity')->nullable();
$table->integer('sort_order')->default(0);
$table->timestamps();
$table->unique(['event_id', 'name']);
$table->index(['event_id', 'sort_order']);
});
}
public function down(): void
{
Schema::dropIfExists('stages');
}
};

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
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('stage_days', function (Blueprint $table) {
$table->id();
$table->foreignUlid('stage_id')->constrained()->cascadeOnDelete();
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
$table->unique(['stage_id', 'event_id']);
$table->index('event_id');
});
}
public function down(): void
{
Schema::dropIfExists('stage_days');
}
};

View File

@@ -0,0 +1,69 @@
<?php
declare(strict_types=1);
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('artist_engagements', function (Blueprint $table) {
$table->ulid('id')->primary();
$table->foreignUlid('organisation_id')->constrained()->cascadeOnDelete();
$table->foreignUlid('artist_id')->constrained()->cascadeOnDelete();
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
$table->string('booking_status')->default('draft');
$table->foreignUlid('project_leader_id')->nullable()->constrained('users')->nullOnDelete();
// Deal info
$table->decimal('fee_amount', 10, 2)->nullable();
$table->string('fee_currency', 3)->default('EUR');
$table->string('fee_type')->nullable();
$table->boolean('buma_applicable')->default(true);
$table->decimal('buma_percentage', 5, 2)->default(7.00);
$table->string('buma_handled_by')->default('organisation');
$table->boolean('vat_applicable')->default(true);
$table->decimal('vat_percentage', 5, 2)->default(21.00);
$table->json('deal_breakdown')->nullable();
$table->decimal('deposit_percentage', 5, 2)->nullable();
$table->date('deposit_due_date')->nullable();
$table->date('balance_due_date')->nullable();
$table->string('payment_status')->default('none');
// Crew + guests
$table->integer('crew_count')->default(0);
$table->integer('guests_count')->default(0);
// Milestone datetimes (per RFC v0.2 §5.3)
$table->datetime('requested_at')->nullable();
$table->datetime('option_expires_at')->nullable();
$table->datetime('advance_open_from')->nullable();
$table->datetime('advance_open_to')->nullable();
// Portal access
$table->ulid('portal_token')->nullable()->unique();
// Advancing aggregates (recomputed in Session 3)
$table->integer('advancing_completed_count')->default(0);
$table->integer('advancing_total_count')->default(0);
$table->text('notes')->nullable();
$table->timestamps();
$table->softDeletes();
$table->unique(['artist_id', 'event_id']);
$table->index('organisation_id');
$table->index(['event_id', 'booking_status']);
$table->index('option_expires_at');
});
}
public function down(): void
{
Schema::dropIfExists('artist_engagements');
}
};

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
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('performances', function (Blueprint $table) {
$table->ulid('id')->primary();
$table->foreignUlid('engagement_id')->constrained('artist_engagements')->cascadeOnDelete();
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
$table->foreignUlid('stage_id')->nullable()->constrained()->nullOnDelete();
$table->unsignedTinyInteger('lane')->default(0);
$table->datetime('start_at');
$table->datetime('end_at');
$table->integer('version')->default(0);
$table->text('notes')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index(['event_id', 'stage_id', 'start_at', 'end_at']);
$table->index('engagement_id');
$table->index(['stage_id', 'start_at']);
});
}
public function down(): void
{
Schema::dropIfExists('performances');
}
};

View File

@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
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('advance_sections', function (Blueprint $table) {
$table->ulid('id')->primary();
$table->foreignUlid('engagement_id')->constrained('artist_engagements')->cascadeOnDelete();
$table->string('name', 80);
$table->string('type');
$table->boolean('is_open')->default(false);
$table->datetime('open_from')->nullable();
$table->datetime('open_to')->nullable();
$table->integer('sort_order')->default(0);
$table->string('submission_status')->default('open');
$table->timestamp('last_submitted_at')->nullable();
$table->string('last_submitted_by')->nullable();
$table->json('submission_diff')->nullable();
$table->timestamps();
$table->index(['engagement_id', 'is_open']);
$table->index(['engagement_id', 'submission_status']);
});
}
public function down(): void
{
Schema::dropIfExists('advance_sections');
}
};

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
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('advance_submissions', function (Blueprint $table) {
$table->ulid('id')->primary();
$table->foreignUlid('advance_section_id')->constrained()->cascadeOnDelete();
$table->string('submitted_by_name');
$table->string('submitted_by_email');
$table->timestamp('submitted_at');
$table->string('status')->default('pending');
$table->foreignUlid('reviewed_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamp('reviewed_at')->nullable();
$table->json('data');
$table->timestamps();
$table->index(['advance_section_id', 'status']);
});
}
public function down(): void
{
Schema::dropIfExists('advance_submissions');
}
};