<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('persetujuan_penawaran', function (Blueprint $table) {
           $table->unsignedBigInteger('penawaran_id')->change()->nullable();
           $table->unsignedBigInteger('permohonan_id')->nullable();

           $table->foreign('permohonan_id')->references('id')->on('permohonan')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('persetujuan_penawaran', function (Blueprint $table) {
            $table->unsignedBigInteger('penawaran_id')->change()->nullable(false);
            $table->dropForeign('persetujuan_penawaran_permohonan_id_foreign');
            $table->dropColumn('permohonan_id');
        });
    }
};
