<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
    use Modules\Lpj\Models\Permohonan;

    return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('penilaian', function (Blueprint $table) {
            $table->dropColumn('user_id');
            $table->string('nomor_registrasi')->references('nomor_registrasi')->on(Permohonan::class)->onDelete('cascade');
            $table->unsignedBigInteger('penilaian_id')->unsigned()->nullable();
            $table->unsignedBigInteger('surveyor_id')->unsigned()->nullable();
            $table->unsignedBigInteger('penilai_surveyor_id')->unsigned()->nullable();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('penilaian', function (Blueprint $table) {
            $table->unsignedBigInteger('user_id')->unsigned();
            $table->dropColumn('nomor_registrasi');
            $table->dropColumn('penilaian_id');
            $table->dropColumn('surveyor_id');
            $table->dropColumn('penilai_surveyor_id');
        });
    }
};
