<?php

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

return new class extends Migration
{
    /**
     * 가지급금 카테고리 컬럼 추가
     * D1.7 기획서: 카드/경조사/상품권/접대비 4개 카테고리 분류
     */
    public function up(): void
    {
        Schema::table('loans', function (Blueprint $table) {
            $table->string('category', 30)
                ->default('card')
                ->after('status')
                ->comment('카테고리: card, congratulatory, gift_certificate, entertainment');

            $table->index(['tenant_id', 'category'], 'idx_tenant_category');
        });
    }

    public function down(): void
    {
        Schema::table('loans', function (Blueprint $table) {
            $table->dropIndex('idx_tenant_category');
            $table->dropColumn('category');
        });
    }
};