<?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('interview_templates', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
            $table->unsignedBigInteger('interview_category_id')->comment('카테고리 ID');
            $table->string('name', 200)->comment('항목명 (예: 견적서 제작)');
            $table->text('description')->nullable()->comment('설명');
            $table->unsignedInteger('sort_order')->default(0)->comment('정렬순서');
            $table->boolean('is_active')->default(true)->comment('활성여부');
            $table->unsignedBigInteger('created_by')->nullable()->comment('등록자');
            $table->unsignedBigInteger('updated_by')->nullable()->comment('수정자');
            $table->unsignedBigInteger('deleted_by')->nullable()->comment('삭제자');
            $table->timestamps();
            $table->softDeletes();

            $table->index('tenant_id', 'idx_interview_templates_tenant');
            $table->index('interview_category_id', 'idx_interview_templates_category');
            $table->index('sort_order', 'idx_interview_templates_sort');
        });
    }

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