feat: fase 2 backend — crowd types, persons, sections, shifts, invite flow
- Crowd Types + Persons CRUD (73 tests) - Festival Sections + Time Slots + Shifts CRUD met assign/claim flow (84 tests) - Invite Flow + Member Management met InvitationService (109 tests) - Schema v1.6 migraties volledig uitgevoerd - DevSeeder bijgewerkt met crowd types voor testorganisatie
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?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('locations', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('address')->nullable();
|
||||
$table->decimal('lat', 10, 8)->nullable();
|
||||
$table->decimal('lng', 11, 8)->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->text('access_instructions')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index('event_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('locations');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('festival_sections', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->unsignedInteger('sort_order')->default(0);
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['event_id', 'sort_order']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('festival_sections');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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('time_slots', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->enum('person_type', ['CREW', 'VOLUNTEER', 'PRESS', 'PHOTO', 'PARTNER'])->default('VOLUNTEER');
|
||||
$table->date('date');
|
||||
$table->time('start_time');
|
||||
$table->time('end_time');
|
||||
$table->decimal('duration_hours', 4, 2)->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['event_id', 'person_type', 'date']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('time_slots');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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('events', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('events', 'volunteer_min_hours_for_pass')) {
|
||||
$table->dropColumn('volunteer_min_hours_for_pass');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('events', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('events', 'volunteer_min_hours_for_pass')) {
|
||||
$table->decimal('volunteer_min_hours_for_pass', 4, 2)->nullable()->after('status');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?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('locations', function (Blueprint $table) {
|
||||
if (Schema::hasColumn('locations', 'route_geojson')) {
|
||||
$table->dropColumn('route_geojson');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('locations', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('locations', 'route_geojson')) {
|
||||
$table->json('route_geojson')->nullable()->after('access_instructions');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
<?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('festival_sections', function (Blueprint $table) {
|
||||
$table->enum('type', ['standard', 'cross_event'])->default('standard')->after('name');
|
||||
$table->unsignedInteger('crew_need')->nullable()->after('type');
|
||||
$table->boolean('crew_auto_accepts')->default(false)->after('sort_order');
|
||||
$table->boolean('crew_invited_to_events')->default(false)->after('crew_auto_accepts');
|
||||
$table->boolean('added_to_timeline')->default(false)->after('crew_invited_to_events');
|
||||
$table->boolean('responder_self_checkin')->default(true)->after('added_to_timeline');
|
||||
$table->string('crew_accreditation_level')->nullable()->after('responder_self_checkin');
|
||||
$table->string('public_form_accreditation_level')->nullable()->after('crew_accreditation_level');
|
||||
$table->boolean('timed_accreditations')->default(false)->after('public_form_accreditation_level');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('festival_sections', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'type',
|
||||
'crew_need',
|
||||
'crew_auto_accepts',
|
||||
'crew_invited_to_events',
|
||||
'added_to_timeline',
|
||||
'responder_self_checkin',
|
||||
'crew_accreditation_level',
|
||||
'public_form_accreditation_level',
|
||||
'timed_accreditations',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
<?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('shifts', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('festival_section_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('time_slot_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('location_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->time('report_time')->nullable();
|
||||
$table->string('title')->nullable();
|
||||
$table->text('description')->nullable();
|
||||
$table->text('instructions')->nullable();
|
||||
$table->text('coordinator_notes')->nullable();
|
||||
$table->unsignedInteger('slots_total');
|
||||
$table->unsignedInteger('slots_open_for_claiming');
|
||||
$table->boolean('is_lead_role')->default(false);
|
||||
$table->time('actual_start_time')->nullable();
|
||||
$table->time('actual_end_time')->nullable();
|
||||
$table->date('end_date')->nullable();
|
||||
$table->boolean('allow_overlap')->default(false);
|
||||
$table->json('events_during_shift')->nullable();
|
||||
$table->enum('status', ['draft', 'open', 'full', 'in_progress', 'completed', 'cancelled'])->default('draft');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['festival_section_id', 'time_slot_id']);
|
||||
$table->index(['time_slot_id', 'status']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('shifts');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
<?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('shift_assignments', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('shift_id')->constrained()->cascadeOnDelete();
|
||||
$table->char('person_id', 26);
|
||||
$table->foreignUlid('time_slot_id')->constrained()->cascadeOnDelete();
|
||||
$table->enum('status', ['pending_approval', 'approved', 'rejected', 'cancelled', 'completed'])->default('pending_approval');
|
||||
$table->boolean('auto_approved')->default(false);
|
||||
$table->foreignUlid('assigned_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamp('assigned_at')->nullable();
|
||||
$table->foreignUlid('approved_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamp('approved_at')->nullable();
|
||||
$table->text('rejection_reason')->nullable();
|
||||
$table->decimal('hours_expected', 4, 2)->nullable();
|
||||
$table->decimal('hours_completed', 4, 2)->nullable();
|
||||
$table->timestamp('checked_in_at')->nullable();
|
||||
$table->timestamp('checked_out_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['person_id', 'time_slot_id']);
|
||||
$table->index(['shift_id', 'status']);
|
||||
$table->index(['person_id', 'status']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('shift_assignments');
|
||||
}
|
||||
};
|
||||
@@ -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('shift_check_ins', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('shift_assignment_id')->constrained()->cascadeOnDelete();
|
||||
$table->char('person_id', 26);
|
||||
$table->foreignUlid('shift_id')->constrained()->cascadeOnDelete();
|
||||
$table->timestamp('checked_in_at');
|
||||
$table->timestamp('checked_out_at')->nullable();
|
||||
$table->foreignUlid('checked_in_by_user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->enum('method', ['qr', 'manual']);
|
||||
|
||||
$table->index('shift_assignment_id');
|
||||
$table->index(['shift_id', 'checked_in_at']);
|
||||
$table->index(['person_id', 'checked_in_at']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('shift_check_ins');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('volunteer_availabilities', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->char('person_id', 26);
|
||||
$table->foreignUlid('time_slot_id')->constrained()->cascadeOnDelete();
|
||||
$table->tinyInteger('preference_level')->default(3);
|
||||
$table->timestamp('submitted_at');
|
||||
|
||||
$table->unique(['person_id', 'time_slot_id']);
|
||||
$table->index('time_slot_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('volunteer_availabilities');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
<?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('event_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->enum('booking_status', ['concept', 'requested', 'option', 'confirmed', 'contracted', 'cancelled'])->default('concept');
|
||||
$table->tinyInteger('star_rating')->default(1);
|
||||
$table->foreignUlid('project_leader_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->boolean('milestone_offer_in')->default(false);
|
||||
$table->boolean('milestone_offer_agreed')->default(false);
|
||||
$table->boolean('milestone_confirmed')->default(false);
|
||||
$table->boolean('milestone_announced')->default(false);
|
||||
$table->boolean('milestone_schedule_confirmed')->default(false);
|
||||
$table->boolean('milestone_itinerary_sent')->default(false);
|
||||
$table->boolean('milestone_advance_sent')->default(false);
|
||||
$table->boolean('milestone_advance_received')->default(false);
|
||||
$table->datetime('advance_open_from')->nullable();
|
||||
$table->datetime('advance_open_to')->nullable();
|
||||
$table->boolean('show_advance_share_page')->default(true);
|
||||
$table->char('portal_token', 26)->unique();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('event_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('artists');
|
||||
}
|
||||
};
|
||||
@@ -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('artist_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->enum('type', ['guest_list', 'contacts', 'production', 'custom']);
|
||||
$table->boolean('is_open')->default(false);
|
||||
$table->datetime('open_from')->nullable();
|
||||
$table->datetime('open_to')->nullable();
|
||||
$table->unsignedInteger('sort_order')->default(0);
|
||||
$table->enum('submission_status', ['open', 'pending', 'submitted', 'approved', 'declined'])->default('open');
|
||||
$table->timestamp('last_submitted_at')->nullable();
|
||||
$table->string('last_submitted_by')->nullable();
|
||||
$table->json('submission_diff')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['artist_id', 'is_open']);
|
||||
$table->index(['artist_id', 'submission_status']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('advance_sections');
|
||||
}
|
||||
};
|
||||
@@ -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('crowd_types', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('organisation_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->enum('system_type', ['CREW', 'GUEST', 'ARTIST', 'VOLUNTEER', 'PRESS', 'PARTNER', 'SUPPLIER']);
|
||||
$table->string('color')->default('#6366f1');
|
||||
$table->string('icon')->nullable();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['organisation_id', 'system_type']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('crowd_types');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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('companies', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('organisation_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->enum('type', ['supplier', 'partner', 'agency', 'venue', 'other']);
|
||||
$table->string('contact_name')->nullable();
|
||||
$table->string('contact_email')->nullable();
|
||||
$table->string('contact_phone')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index('organisation_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('companies');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
<?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('persons', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('user_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('crowd_type_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('company_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->string('name');
|
||||
$table->string('email');
|
||||
$table->string('phone')->nullable();
|
||||
$table->enum('status', ['invited', 'applied', 'pending', 'approved', 'rejected', 'no_show'])->default('pending');
|
||||
$table->boolean('is_blacklisted')->default(false);
|
||||
$table->text('admin_notes')->nullable();
|
||||
$table->json('custom_fields')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->index(['event_id', 'crowd_type_id', 'status']);
|
||||
$table->index(['email', 'event_id']);
|
||||
$table->index(['user_id', 'event_id']);
|
||||
});
|
||||
|
||||
// Conditional unique: one user can only appear once per event
|
||||
// MySQL doesn't support partial indexes, so we use a unique index
|
||||
// that only fires when user_id is not null (handled at application level)
|
||||
// The composite index (user_id, event_id) already exists above
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('persons');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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('crowd_lists', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('event_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('crowd_type_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->enum('type', ['internal', 'external']);
|
||||
$table->foreignUlid('recipient_company_id')->nullable()->constrained('companies')->nullOnDelete();
|
||||
$table->boolean('auto_approve')->default(false);
|
||||
$table->unsignedInteger('max_persons')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['event_id', 'type']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('crowd_lists');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
<?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('crowd_list_persons', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignUlid('crowd_list_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('person_id')->constrained('persons')->cascadeOnDelete();
|
||||
$table->timestamp('added_at');
|
||||
$table->foreignUlid('added_by_user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
|
||||
$table->unique(['crowd_list_id', 'person_id']);
|
||||
$table->index('person_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('crowd_list_persons');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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('shift_assignments', function (Blueprint $table) {
|
||||
$table->foreign('person_id')->references('id')->on('persons')->cascadeOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('shift_check_ins', function (Blueprint $table) {
|
||||
$table->foreign('person_id')->references('id')->on('persons')->cascadeOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('volunteer_availabilities', function (Blueprint $table) {
|
||||
$table->foreign('person_id')->references('id')->on('persons')->cascadeOnDelete();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('shift_assignments', function (Blueprint $table) {
|
||||
$table->dropForeign(['person_id']);
|
||||
});
|
||||
|
||||
Schema::table('shift_check_ins', function (Blueprint $table) {
|
||||
$table->dropForeign(['person_id']);
|
||||
});
|
||||
|
||||
Schema::table('volunteer_availabilities', function (Blueprint $table) {
|
||||
$table->dropForeign(['person_id']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
<?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
|
||||
{
|
||||
// Add assigned_crew_id to shifts
|
||||
Schema::table('shifts', function (Blueprint $table) {
|
||||
$table->foreignUlid('assigned_crew_id')->nullable()->after('allow_overlap')->constrained('users')->nullOnDelete();
|
||||
});
|
||||
|
||||
// Shift waitlist
|
||||
Schema::create('shift_waitlist', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('shift_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('person_id')->constrained('persons')->cascadeOnDelete();
|
||||
$table->unsignedInteger('position');
|
||||
$table->timestamp('added_at');
|
||||
$table->timestamp('notified_at')->nullable();
|
||||
|
||||
$table->unique(['shift_id', 'person_id']);
|
||||
$table->index(['shift_id', 'position']);
|
||||
});
|
||||
|
||||
// Shift absences
|
||||
Schema::create('shift_absences', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('shift_assignment_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignUlid('person_id')->constrained('persons')->cascadeOnDelete();
|
||||
$table->enum('reason', ['sick', 'personal', 'other']);
|
||||
$table->timestamp('reported_at');
|
||||
$table->enum('status', ['open', 'filled', 'closed'])->default('open');
|
||||
$table->timestamp('closed_at')->nullable();
|
||||
|
||||
$table->index('shift_assignment_id');
|
||||
$table->index('status');
|
||||
});
|
||||
|
||||
// Shift swap requests
|
||||
Schema::create('shift_swap_requests', function (Blueprint $table) {
|
||||
$table->ulid('id')->primary();
|
||||
$table->foreignUlid('from_assignment_id')->constrained('shift_assignments')->cascadeOnDelete();
|
||||
$table->foreignUlid('to_person_id')->constrained('persons')->cascadeOnDelete();
|
||||
$table->text('message')->nullable();
|
||||
$table->enum('status', ['pending', 'accepted', 'rejected', 'cancelled', 'completed'])->default('pending');
|
||||
$table->foreignUlid('reviewed_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamp('reviewed_at')->nullable();
|
||||
$table->boolean('auto_approved')->default(false);
|
||||
|
||||
$table->index('from_assignment_id');
|
||||
$table->index(['to_person_id', 'status']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('shift_swap_requests');
|
||||
Schema::dropIfExists('shift_absences');
|
||||
Schema::dropIfExists('shift_waitlist');
|
||||
|
||||
Schema::table('shifts', function (Blueprint $table) {
|
||||
$table->dropForeign(['assigned_crew_id']);
|
||||
$table->dropColumn('assigned_crew_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Drop the UNIQUE(person_id, time_slot_id) constraint on shift_assignments.
|
||||
*
|
||||
* Reason: shifts.allow_overlap = true must allow a person to be assigned
|
||||
* to multiple shifts in the same time slot. MySQL doesn't support partial
|
||||
* unique indexes, so conflict detection is handled in application code.
|
||||
*
|
||||
* @see SCHEMA.md section 3.5.3 — shift_assignments
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('shift_assignments', function (Blueprint $table) {
|
||||
$table->dropUnique(['person_id', 'time_slot_id']);
|
||||
// Keep the composite index for query performance
|
||||
$table->index(['person_id', 'time_slot_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('shift_assignments', function (Blueprint $table) {
|
||||
$table->dropIndex(['person_id', 'time_slot_id']);
|
||||
$table->unique(['person_id', 'time_slot_id']);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user