<?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_consultations', function (Blueprint $table) {
            $table->id();
            $table->foreignId('prospect_id')->constrained('sales_prospects')->cascadeOnDelete();
            $table->foreignId('manager_id')->constrained('sales_managers')->cascadeOnDelete();
            $table->enum('scenario_type', ['sales', 'manager'])->default('manager')->comment('시나리오 유형');
            $table->unsignedInteger('step_id')->nullable()->comment('단계 ID');
            $table->text('log_text')->comment('상담 내용');
            $table->string('audio_file_path', 500)->nullable()->comment('음성 파일 경로');
            $table->json('attachment_paths')->nullable()->comment('첨부파일 경로 목록');
            $table->enum('consultation_type', ['text', 'audio', 'file'])->default('text')->comment('상담 유형');
            $table->timestamps();
            $table->softDeletes();

            $table->index('prospect_id');
            $table->index('manager_id');
            $table->index('scenario_type');
        });
    }

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