<?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_purtare', function (Blueprint $table) {
            $table->id();
            $table->foreignId('elev_id')->constrained('elevi')->onDelete('cascade');
            $table->foreignId('perioada_id')->constrained('perioade')->onDelete('cascade');
            $table->integer('valoare')->default(10);
            $table->text('observatii')->nullable();
            $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();
            $table->unique(['elev_id', 'perioada_id']);
        });
    }

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