<?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('booking_participants', function (Blueprint $table) {
            $table->id();
            $table->foreignId('booking_id')->constrained('bookings')->cascadeOnDelete();
            $table->foreignId('member_id')->nullable()->constrained('members')->cascadeOnDelete();
            $table->foreignId('dependent_id')->nullable()->constrained('dependents')->cascadeOnDelete();
            $table->tinyInteger('status')->default(1); // BookingParticipantStatusEnum: Pending
            $table->boolean('is_creator')->default(false);
            $table->timestamps();
        });

        Schema::table('booking_participants', function (Blueprint $table) {
            $table->index(['booking_id']);
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('booking_participants');
    }
};
