<?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('setting_katrol', function (Blueprint $table) {
            $table->id();
            $table->foreignId('ujian_id')->constrained('ujian')->cascadeOnDelete();
            $table->foreignId('guru_mengajar_id')->constrained('guru_mengajar')->cascadeOnDelete();
            $table->decimal('kkm', 5, 2)->default(75);
            $table->decimal('nilai_minimum_raport', 5, 2)->default(75); // nilai raport terendah
            $table->decimal('nilai_maximum_raport', 5, 2)->default(90); // nilai raport tertinggi
            $table->boolean('is_applied')->default(false); // sudah diapply katrol?
            $table->timestamps();

            $table->unique('ujian_id');
            $table->index('guru_mengajar_id');
        });
    }

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