<?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('esign_field_templates', function (Blueprint $table) {
            $table->id();
            $table->foreignId('tenant_id')->constrained()->onDelete('cascade')->comment('테넌트 ID');
            $table->string('name', 100)->comment('템플릿 이름');
            $table->text('description')->nullable()->comment('템플릿 설명');
            $table->unsignedTinyInteger('signer_count')->default(2)->comment('서명자 수');
            $table->boolean('is_active')->default(true)->comment('활성 여부');
            $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete()->comment('생성자 ID');
            $table->timestamps();

            $table->index('tenant_id', 'idx_esign_field_templates_tenant');
            $table->index('is_active', 'idx_esign_field_templates_active');
        });
    }

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