<?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('approvals', function (Blueprint $table) {
            $table->foreignId('line_id')->nullable()->after('form_id')
                ->constrained('approval_lines')->nullOnDelete()
                ->comment('결재선 템플릿 ID');
            $table->longText('body')->nullable()->after('content')
                ->comment('본문 내용');
            $table->boolean('is_urgent')->default(false)->after('status')
                ->comment('긴급 여부');
            $table->unsignedBigInteger('department_id')->nullable()->after('drafter_id')
                ->comment('기안 부서 ID');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('approvals', function (Blueprint $table) {
            $table->dropForeign(['line_id']);
            $table->dropColumn(['line_id', 'body', 'is_urgent', 'department_id']);
        });
    }
};
