<?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('pieces_jointes', function (Blueprint $table) {
            $table->id();
            $table->foreignId('candidat_id')->constrained('candidats')->cascadeOnDelete();
            $table->string('type_document', 50)->notNull();
            $table->string('nom_fichier_original', 255)->notNull();
            $table->string('chemin_stockage', 500)->notNull();
            $table->string('mime_type', 100)->nullable();
            $table->bigInteger('taille_octets')->nullable();
            $table->string('statut_validation', 20)->default('en_attente');
            $table->text('commentaire_rejet')->nullable();
            $table->date('date_expiration')->nullable();
            $table->foreignId('valide_par')->nullable()->constrained('users')->nullOnDelete();
            $table->timestamp('valide_at')->nullable();
            $table->timestamps();
        });
    }

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