<?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('barobill_members', function (Blueprint $table) {
            $table->id();
            $table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
            $table->string('biz_no', 20)->comment('사업자번호');
            $table->string('corp_name', 100)->comment('상호명');
            $table->string('ceo_name', 50)->comment('대표자명');
            $table->string('addr', 255)->nullable()->comment('주소');
            $table->string('biz_type', 50)->nullable()->comment('업태');
            $table->string('biz_class', 50)->nullable()->comment('종목');
            $table->string('barobill_id', 50)->comment('바로빌 아이디');
            $table->string('barobill_pwd', 255)->comment('바로빌 비밀번호 (해시)');
            $table->string('manager_name', 50)->nullable()->comment('담당자명');
            $table->string('manager_email', 100)->nullable()->comment('담당자 이메일');
            $table->string('manager_hp', 20)->nullable()->comment('담당자 전화번호');
            $table->enum('status', ['active', 'inactive', 'pending'])->default('active')->comment('상태');
            $table->timestamps();
            $table->softDeletes();

            $table->unique(['tenant_id', 'biz_no'], 'unique_tenant_biz_no');
            $table->index('status');
        });
    }

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