<?php

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

return new class extends Migration
{
    /**
     * Add missing indexes for frequently queried columns.
     */
    public function up(): void
    {
        Schema::table('ads', function (Blueprint $table) {
            $table->index(['position', 'is_active'], 'ads_position_is_active_index');
        });

        Schema::table('applications', function (Blueprint $table) {
            $table->index('status', 'applications_status_index');
        });

        Schema::table('notification_logs', function (Blueprint $table) {
            $table->index('type', 'notification_logs_type_index');
            $table->index('channel', 'notification_logs_channel_index');
        });

        Schema::table('settings', function (Blueprint $table) {
            $table->index('group', 'settings_group_index');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('ads', function (Blueprint $table) {
            $table->dropIndex('ads_position_is_active_index');
        });

        Schema::table('applications', function (Blueprint $table) {
            $table->dropIndex('applications_status_index');
        });

        Schema::table('notification_logs', function (Blueprint $table) {
            $table->dropIndex('notification_logs_type_index');
            $table->dropIndex('notification_logs_channel_index');
        });

        Schema::table('settings', function (Blueprint $table) {
            $table->dropIndex('settings_group_index');
        });
    }
};
