<?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('note', function (Blueprint $table) {
            $table->id();
            $table->foreignId('elev_id')->constrained('elevi')->onDelete('cascade');
            $table->foreignId('materie_id')->constrained('materii')->onDelete('cascade');
            $table->integer('valoare'); // 1-10
            $table->date('data');
            $table->integer('semestru'); // 1 sau 2
            $table->string('tip')->default('curenta'); // curenta, teza, final
            $table->text('observatii')->nullable();
            // Audit log - obligatoriu MEN
            $table->foreignId('adaugat_de')->constrained('users');
            $table->timestamp('adaugat_la');
            $table->foreignId('modificat_de')->nullable()->constrained('users');
            $table->timestamp('modificat_la')->nullable();
            $table->text('motiv_modificare')->nullable();
            $table->timestamps();
        });
    }

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