<?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('permohonan', function (Blueprint $table) {
            // nullable
            $table->unsignedBigInteger('branch_id')->nullable()->change();
            $table->unsignedBigInteger('user_id')->nullable()->change();


            $table->unsignedBigInteger('mig_kd_debitur_seq')->nullable()->comment('asal data LPJ.PRM_DEBITUR.KD_DEBITUR_SEQ. Berguna untuk update debitur_id menggunakan KD_DEBITUR_SEQ nya');
            $table->unsignedBigInteger('nomor_lpj')->nullable();
            $table->string('mig_nama_ao')->nullable();
            $table->char('is_mig', 1)->nullable()->comment('untuk menandakan row ini dari LPJ OLD');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('permohonan', function (Blueprint $table) {
            // Kembalikan kolom branch_id agar tidak nullable (asumsi awal NOT NULL)
            $table->unsignedBigInteger('branch_id')->nullable(false)->change();
            $table->unsignedBigInteger('user_id')->nullable(false)->change();



            // Hapus kolom tambahan yang dibuat di up()
            $table->dropColumn([
                'mig_kd_debitur_seq',
                'nomor_lpj',
                'mig_nama_ao',
                'is_mig'
            ]);
        });
    }
};
