<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
         Schema::create('hasil_penilaian', function (Blueprint $table) {
            $table->id();
            
            $table->foreignId('pengajuan_id')
                  ->constrained('pengajuan_ukts')
                  ->onDelete('restrict'); // Ganti cascade dengan restrict untuk mencegah penghapusan
            
            $table->decimal('nilai_preferensi', 8, 6); // Contoh: 2 digit sebelum koma, 6 setelah
            
            $table->string('rekomendasi_ukt', 20);
            $table->text('keterangan')->nullable();
            
            $table->foreignId('processed_by')
                  ->nullable()
                  ->constrained('users')
                  ->onDelete('set null');
            
            $table->timestamps();

            $table->index('nilai_preferensi');
            $table->index('rekomendasi_ukt');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('hasil_penilaian');
    }
};