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

            $table->id();

            $table->foreignId('user_id')->constrained()->cascadeOnDelete();
            
            $table->string('outbound_ar');
            $table->string('outbound_en');
            $table->string('outbound_zh');

            $table->string('inbound_ar');
            $table->string('inbound_en');
            $table->string('inbound_zh');

            $table->string('description_ar', 255)->nullable();
            $table->string('description_en', 255)->nullable();
            $table->string('description_zh', 255)->nullable();

            $table->dateTime('departure_at');

            $table->boolean('is_active')->default(true);

            $table->timestamps();

            /*
            |--------------------------------------------------------------------------
            | INDEXES
            |--------------------------------------------------------------------------
            */

            $table->index(['is_active', 'departure_at']);

            $table->index('departure_at');
            $table->index('is_active');

            // outbound indexes
            $table->index('outbound_ar');
            $table->index('outbound_en');
            $table->index('outbound_zh');

            // inbound indexes
            $table->index('inbound_ar');
            $table->index('inbound_en');
            $table->index('inbound_zh');

            // description indexes
            $table->index('description_ar');
            $table->index('description_en');
            $table->index('description_zh');
        });
    }

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