<?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('international_tour_itineraries', function (Blueprint $table) {
            $table->id();

            $table->unsignedBigInteger('international_tour_id');

            $table->integer('day_number');
            $table->string('title');
            $table->text('description')->nullable();
            $table->string('location')->nullable();
            $table->integer('sort_order')->default(0);
            $table->boolean('is_active')->default(true);
            $table->timestamps();
            $table->softDeletes();

            $table->foreign('international_tour_id')->references('id')->on('international_tours')->onDelete('cascade');

            $table->index(['international_tour_id', 'day_number', 'sort_order'], 'idx_it_itin_tour_day_sort');
            $table->index(['international_tour_id', 'is_active'], 'idx_it_itin_tour_active');

            $table->fullText(['title', 'description', 'location'], 'ft_it_itin_content');

            $table->unique(['international_tour_id', 'day_number', 'sort_order'], 'unique_intl_tour_day_order');
        });
    }

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