<?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::table('movies', function (Blueprint $table) {
            $table->index(['is_active', 'created_at'], 'movies_home_latest_idx');
            $table->index(['is_active', 'release_date'], 'movies_home_date_idx');
        });

        Schema::table('shows', function (Blueprint $table) {
            $table->index(['is_active', 'created_at'], 'shows_home_latest_idx');
            $table->index(['is_active', 'first_air_date'], 'shows_home_date_idx');
        });
    }

    public function down(): void
    {
        Schema::table('movies', function (Blueprint $table) {
            $table->dropIndex('movies_home_latest_idx');
            $table->dropIndex('movies_home_date_idx');
        });

        Schema::table('shows', function (Blueprint $table) {
            $table->dropIndex('shows_home_latest_idx');
            $table->dropIndex('shows_home_date_idx');
        });
    }
};
