<?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('penilaian', function (Blueprint $table) {
            $table->id();
            $table->string('nim_mahasiswa');
            $table->string('nip_penguji');
            $table->integer('penguji_ke'); // Penguji ke 1 sampai 5
            $table->text('catatan')->nullable(); // Catatan atau saran penguji
            $table->float('nilai_total')->default(0); // Hasil rumus sum(bobot x nilai) / jumlah bobot
            $table->timestamps();

            $table->foreign('nim_mahasiswa')->references('nim')->on('mahasiswa')->onDelete('cascade');
            $table->foreign('nip_penguji')->references('nip')->on('dosen')->onDelete('cascade');
        });
    }

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