<?php

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

class CreatePermohonanPembatalansTable extends Migration
{
    public function up()
    {
        Schema::create('permohonan_pembatalan', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('permohonan_id');
            $table->text('alasan_pembatalan');
            $table->string('file_pembatalan');
            $table->enum('status', ['pending', 'approved', 'rejected'])->default('pending');
            $table->text('keterangan')->nullable();
            $table->timestamps();
            $table->timestamp('authorized_at')->nullable();
            $table->char('authorized_status', 1)->nullable();
            $table->softDeletes();
            $table->unsignedBigInteger('created_by')->nullable();
            $table->unsignedBigInteger('updated_by')->nullable();
            $table->unsignedBigInteger('deleted_by')->nullable();
            $table->unsignedBigInteger('authorized_by')->nullable();

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

    public function down()
    {
        Schema::dropIfExists('permohonan_pembatalan');
    }
}
