<?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_settings', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('tenant_id')->unique()->comment('테넌트 ID');
            $table->string('corp_num', 20)->comment('사업자번호 (하이픈 제외)');
            $table->string('cert_key')->nullable()->comment('바로빌 인증키 (암호화)');
            $table->string('barobill_id', 100)->nullable()->comment('바로빌 아이디');
            $table->string('corp_name', 100)->comment('상호');
            $table->string('ceo_name', 50)->comment('대표자명');
            $table->string('addr', 200)->nullable()->comment('사업장 주소');
            $table->string('biz_type', 100)->nullable()->comment('업태');
            $table->string('biz_class', 100)->nullable()->comment('종목');
            $table->string('contact_id', 100)->nullable()->comment('담당자 이메일');
            $table->string('contact_name', 50)->nullable()->comment('담당자명');
            $table->string('contact_tel', 20)->nullable()->comment('담당자 전화번호');
            $table->boolean('is_active')->default(false)->comment('활성화 여부');
            $table->boolean('auto_issue')->default(false)->comment('자동 발행 여부');
            $table->timestamp('verified_at')->nullable()->comment('연동 검증일시');
            $table->unsignedBigInteger('created_by')->nullable()->comment('생성자');
            $table->unsignedBigInteger('updated_by')->nullable()->comment('수정자');
            $table->timestamps();

            $table->index('corp_num', 'idx_corp_num');
        });
    }

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