<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('business_card_requests', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
            $table->unsignedBigInteger('user_id')->comment('신청자 ID');

            // 명함 정보
            $table->string('name', 50)->comment('성함');
            $table->string('phone', 20)->comment('전화번호');
            $table->string('title', 50)->nullable()->comment('직함');
            $table->string('email', 100)->nullable()->comment('이메일');
            $table->unsignedInteger('quantity')->default(100)->comment('수량');
            $table->text('memo')->nullable()->comment('비고');

            // 처리 상태
            $table->string('status', 20)->default('pending')->comment('상태: pending, processed');
            $table->unsignedBigInteger('processed_by')->nullable()->comment('처리자 ID');
            $table->timestamp('processed_at')->nullable()->comment('처리일시');
            $table->text('process_memo')->nullable()->comment('처리 메모');

            $table->timestamps();

            // 인덱스
            $table->index(['tenant_id', 'status']);
            $table->index('user_id');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('business_card_requests');
    }
};
