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

            $table->unsignedBigInteger('day_trip_tour_id');

            $table->enum('point_type', ['pickup', 'dropoff'])->default('pickup');
            $table->string('name');
            $table->text('description')->nullable();
            $table->string('address')->nullable();
            $table->decimal('latitude', 10, 8)->nullable();
            $table->decimal('longitude', 11, 8)->nullable();
            $table->time('pickup_time')->nullable();
            $table->integer('sort_order')->default(0);
            $table->boolean('is_active')->default(true);

            $table->timestamps();

            // Foreign Keys
            $table->foreign('day_trip_tour_id')->references('id')->on('day_trip_tours')->onDelete('cascade');

            // Indexes
            $table->index(['day_trip_tour_id', 'point_type', 'sort_order'], 'idx_dtt_transfer_points');
        });
    }

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