<?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_answers', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
            $table->unsignedBigInteger('interview_session_id')->comment('세션 ID');
            $table->unsignedBigInteger('interview_question_id')->comment('질문 ID');
            $table->unsignedBigInteger('interview_template_id')->comment('템플릿 ID (비정규화)');
            $table->boolean('is_checked')->default(false)->comment('체크 여부');
            $table->text('answer_text')->nullable()->comment('텍스트 답변');
            $table->text('memo')->nullable()->comment('개별 메모');
            $table->timestamps();

            $table->unique(['interview_session_id', 'interview_question_id'], 'uniq_session_question');
            $table->index('tenant_id', 'idx_interview_answers_tenant');
            $table->index('interview_template_id', 'idx_interview_answers_template');
        });
    }

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