<?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_sessions', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
            $table->unsignedBigInteger('interview_category_id')->comment('사용한 카테고리 ID');
            $table->unsignedBigInteger('interviewer_id')->comment('면담자(매니저) ID');
            $table->string('interviewee_name', 100)->nullable()->comment('면담 상대 이름');
            $table->string('interviewee_company', 200)->nullable()->comment('면담 상대 회사');
            $table->date('interview_date')->comment('면담 일자');
            $table->string('status', 20)->default('in_progress')->comment('상태: in_progress/completed');
            $table->unsignedInteger('total_questions')->default(0)->comment('총 질문 수');
            $table->unsignedInteger('answered_questions')->default(0)->comment('답변 완료 수');
            $table->text('memo')->nullable()->comment('메모');
            $table->timestamp('completed_at')->nullable()->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', 'interviewer_id'], 'idx_interview_sessions_tenant_interviewer');
            $table->index('interview_category_id', 'idx_interview_sessions_category');
            $table->index('interview_date', 'idx_interview_sessions_date');
            $table->index('status', 'idx_interview_sessions_status');
        });
    }

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