<?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('cards', function (Blueprint $table) {
            $table->string('card_type', 50)->nullable()->after('card_company')->comment('카드 종류 (corporate_1, personal 등)');
            $table->string('alias', 100)->nullable()->after('card_name')->comment('카드 별칭');
            $table->text('cvc_encrypted')->nullable()->after('card_password_encrypted')->comment('암호화된 CVC/CVV');
            $table->unsignedTinyInteger('payment_day')->nullable()->after('cvc_encrypted')->comment('결제일 (1-31)');
            $table->decimal('total_limit', 15, 2)->nullable()->after('payment_day')->comment('총 한도');
            $table->decimal('used_amount', 15, 2)->nullable()->after('total_limit')->comment('사용 금액');
            $table->decimal('remaining_limit', 15, 2)->nullable()->after('used_amount')->comment('잔여 한도');
            $table->boolean('is_manual')->default(false)->after('status')->comment('수기 등록 여부');
            $table->text('memo')->nullable()->after('assigned_user_id')->comment('메모');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('cards', function (Blueprint $table) {
            $table->dropColumn([
                'card_type',
                'alias',
                'cvc_encrypted',
                'payment_day',
                'total_limit',
                'used_amount',
                'remaining_limit',
                'is_manual',
                'memo',
            ]);
        });
    }
};
