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

            $table->unsignedBigInteger('international_tour_id');

            $table->string('pricing_name');
            $table->text('description')->nullable();

            $table->decimal('adult_price', 10, 2)->nullable();
            $table->decimal('child_price', 10, 2)->nullable();
            $table->decimal('infant_price', 10, 2)->nullable();

            $table->integer('child_min_age')->nullable();
            $table->integer('child_max_age')->nullable();
            $table->integer('infant_max_age')->nullable();

            $table->string('currency', 3)->default('TRY');
            $table->integer('sort_order')->default(0);
            $table->boolean('is_active')->default(true);
            $table->boolean('is_default')->default(false);

            $table->timestamps();
            $table->softDeletes();

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

            $table->index(['international_tour_id', 'is_active'], 'idx_itp_tour_active');
            $table->index(['international_tour_id', 'is_default'], 'idx_itp_tour_default');
            $table->index(['sort_order']);
            $table->index(['currency', 'is_active'], 'idx_itp_currency_active');
        });
    }

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