<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Supports the Bookings & Revenue report's filters — travel_date/status/
     * created_by_channel on bookings and completed_at on payments had no
     * standalone index before this (only openid and the composite
     * [ev_route_id, travel_date, departure_time_slot_id] existed).
     */
    public function up(): void
    {
        Schema::table('bookings', function (Blueprint $table) {
            $table->index('travel_date');
            $table->index('status');
            $table->index('created_by_channel');
        });

        Schema::table('payments', function (Blueprint $table) {
            $table->index('completed_at');
        });
    }

    public function down(): void
    {
        Schema::table('bookings', function (Blueprint $table) {
            $table->dropIndex(['travel_date']);
            $table->dropIndex(['status']);
            $table->dropIndex(['created_by_channel']);
        });

        Schema::table('payments', function (Blueprint $table) {
            $table->dropIndex(['completed_at']);
        });
    }
};
