<?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('formations', function (Blueprint $table) {
            $table->id();
            $table->foreignId('candidat_id')->constrained('candidats')->cascadeOnDelete();
            $table->foreignId('formateur_id')->nullable()->constrained('users')->nullOnDelete();
            $table->enum('type_formation', ['taches_menageres', 'nettoyage_bureaux', 'protocole_service', 'securite', 'autre'])->notNull();
            $table->date('date_debut')->notNull();
            $table->date('date_fin')->nullable();
            $table->tinyInteger('duree_jours')->default(7);
            $table->enum('statut', ['programmee', 'en_cours', 'validee', 'echouee', 'abandonnee'])->default('programmee');
            $table->decimal('note', 4, 2)->nullable();
            $table->text('observations')->nullable();
            $table->timestamps();
        });
    }

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