<?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('wills_cases', function (Blueprint $table) {
            $table->id();
            $table->uuid('slug')->unique();
            $table->foreignId('client_id')->constrained('clients')->cascadeOnDelete();
            $table->string('case_number')->nullable()->index();
            $table->timestamp('opened_at')->nullable();
            $table->timestamp('closed_at')->nullable();
            $table->boolean('is_open')->default(true)->index();
            $table->boolean('is_closed')->default(false);
            $table->date('ifa_referred_date')->nullable();
            $table->string('national_insurance', 20)->nullable()->index();
            $table->boolean('ifa_referred')->default(false);
            $table->string('fee_structure')->nullable();
            $table->string('occupation')->nullable();
            $table->unsignedBigInteger('created_by')->nullable();
            $table->timestamps();
        });
    }

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