<?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_questions', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
            $table->unsignedBigInteger('interview_template_id')->comment('템플릿(항목) ID');
            $table->string('question_text', 500)->comment('질문 내용');
            $table->string('question_type', 20)->default('checkbox')->comment('질문유형: checkbox/text');
            $table->json('options')->nullable()->comment('확장용 옵션');
            $table->boolean('is_required')->default(false)->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_questions_tenant');
            $table->index('interview_template_id', 'idx_interview_questions_template');
            $table->index('sort_order', 'idx_interview_questions_sort');
        });
    }

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