<?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('situatii_scolare', function (Blueprint $table) {
            $table->id();
            $table->foreignId('elev_id')->constrained('elevi')->onDelete('cascade');
            $table->foreignId('perioada_id')->constrained('perioade')->onDelete('cascade');
            $table->decimal('media_generala', 4, 2)->nullable();
            $table->integer('nota_purtare')->default(10);
            $table->string('status')->default('in_curs');
            $table->integer('total_absente')->default(0);
            $table->integer('absente_nemotivate')->default(0);
            $table->integer('nr_corigente')->default(0);
            $table->text('observatii')->nullable();
            $table->boolean('incheiat')->default(false);
            $table->foreignId('incheiat_de')->nullable()->constrained('users');
            $table->timestamp('incheiat_la')->nullable();
            $table->timestamps();
            $table->unique(['elev_id', 'perioada_id']);
        });
    }

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