<?php

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

return new class extends Migration
{
    /**
     * Jalankan migrasi.
     */
    public function up(): void
    {
        // Membuat tabel bobot_kriterias dengan relasi ke kriterias
        Schema::create('bobot_kriterias', function (Blueprint $table) {
            $table->id(); // id sebagai primary key
            $table->unsignedBigInteger('criteria_id'); // Foreign key ke tabel kriterias
            $table->float('bobot'); // Kolom bobot
            $table->timestamps();

            // Menambahkan foreign key constraint
            $table->foreign('criteria_id')->references('id')->on('kriterias')->onDelete('cascade')->onUpdate('cascade');
        });
    }

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