<?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::create('corporate_cards', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('tenant_id');
            $table->string('card_name', 100)->comment('카드명');
            $table->string('card_company', 50)->comment('카드사');
            $table->string('card_number', 30)->comment('카드번호');
            $table->enum('card_type', ['credit', 'debit'])->default('credit')->comment('카드종류');
            $table->tinyInteger('payment_day')->default(15)->comment('결제일');
            $table->decimal('credit_limit', 15, 2)->default(0)->comment('한도');
            $table->decimal('current_usage', 15, 2)->default(0)->comment('현재 사용액');
            $table->string('card_holder_name', 100)->nullable()->comment('이용자명(명의자)');
            $table->string('actual_user', 100)->nullable()->comment('실사용자');
            $table->string('expiry_date', 10)->nullable()->comment('유효기간 YY/MM');
            $table->string('cvc', 10)->nullable()->comment('CVC');
            $table->enum('status', ['active', 'inactive'])->default('active')->comment('상태');
            $table->text('memo')->nullable()->comment('메모');
            $table->timestamps();
            $table->softDeletes();

            $table->index('tenant_id');
            $table->index('status');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('corporate_cards');
    }
};
