<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('sales_prospect_scenarios', function (Blueprint $table) {
            $table->id();
            $table->foreignId('prospect_id')->constrained('sales_prospects')->cascadeOnDelete();
            $table->enum('scenario_type', ['sales', 'manager'])->default('manager')->comment('시나리오 유형');
            $table->unsignedInteger('step_id')->comment('단계 ID');
            $table->unsignedInteger('checkpoint_index')->comment('체크포인트 인덱스');
            $table->boolean('is_checked')->default(false)->comment('체크 여부');
            $table->timestamps();

            $table->unique(['prospect_id', 'scenario_type', 'step_id', 'checkpoint_index'], 'unique_prospect_scenario_step');
            $table->index('prospect_id');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('sales_prospect_scenarios');
    }
};
