<?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_projects', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('tenant_id')->comment('테넌트 ID');
            $table->string('company_name', 200)->comment('대상 회사명');
            $table->string('company_type', 100)->nullable()->comment('업종 (방화셔터, 블라인드 등)');
            $table->string('contact_person', 100)->nullable()->comment('담당자');
            $table->string('contact_info', 200)->nullable()->comment('연락처');
            $table->enum('status', ['draft', 'interviewing', 'analyzing', 'code_generated', 'deployed'])
                ->default('draft')->comment('상태');
            $table->unsignedBigInteger('target_tenant_id')->nullable()->comment('생성될 테넌트 ID');
            $table->json('product_categories')->nullable()->comment('제품 카테고리 목록');
            $table->text('summary')->nullable()->comment('AI 생성 요약');
            $table->unsignedTinyInteger('progress_percent')->default(0)->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_projects_tenant');
            $table->index('status', 'idx_interview_projects_status');
        });
    }

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