<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('audience_files', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->foreignId('appointment_id')->constrained()->cascadeOnDelete();
            $table->foreignId('report_id')->constrained()->cascadeOnDelete();

            $table->string('reference')->unique(); // ex: AUD-2025-00012
            $table->timestamp('opened_at')->nullable();;        // date création dossier
            $table->foreignId('opened_by')->constrained('users');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('audience_files');
    }
};
