<?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::table('park_areas', function (Blueprint $table) {
            // Ride statistics
            $table->integer('ride_count')->default(0);
            $table->integer('coaster_count')->default(0);
            $table->integer('flat_ride_count')->default(0);
            $table->integer('water_ride_count')->default(0);
            
            // Visitor statistics
            $table->integer('daily_capacity')->nullable();
            $table->integer('peak_wait_time')->nullable();
            $table->decimal('average_rating', 3, 2)->nullable();
            
            // Historical data
            $table->integer('total_rides_operated')->default(0);
            $table->integer('retired_rides_count')->default(0);
            $table->date('last_new_ride_added')->nullable();
            
            // Add indexes for common queries
            $table->index(['park_id', 'ride_count']);
            $table->index(['park_id', 'coaster_count']);
            $table->index(['park_id', 'average_rating']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('park_areas', function (Blueprint $table) {
            $table->dropIndex(['park_id', 'ride_count']);
            $table->dropIndex(['park_id', 'coaster_count']);
            $table->dropIndex(['park_id', 'average_rating']);
            
            $table->dropColumn([
                'ride_count',
                'coaster_count',
                'flat_ride_count',
                'water_ride_count',
                'daily_capacity',
                'peak_wait_time',
                'average_rating',
                'total_rides_operated',
                'retired_rides_count',
                'last_new_ride_added',
            ]);
        });
    }
};