<?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('expense_accounts', function (Blueprint $table) {
            $table->unsignedBigInteger('loan_id')->nullable()->after('card_no')
                ->comment('연결된 가지급금 ID (상품권→접대비 전환 시)');

            $table->index('loan_id');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('expense_accounts', function (Blueprint $table) {
            $table->dropIndex(['loan_id']);
            $table->dropColumn('loan_id');
        });
    }
};
