<?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('roller_coaster_stats', function (Blueprint $table) {
            $table->id();
            $table->foreignId('ride_id')->unique()->constrained('rides')->cascadeOnDelete();
            
            // Physical dimensions
            $table->decimal('height_ft', 6, 2)->nullable();
            $table->decimal('length_ft', 7, 2)->nullable();
            $table->decimal('speed_mph', 5, 2)->nullable();
            $table->decimal('max_drop_height_ft', 6, 2)->nullable();
            
            // Track characteristics
            $table->unsignedInteger('inversions')->default(0);
            $table->unsignedInteger('ride_time_seconds')->nullable();
            $table->string('track_type')->default('');
            $table->string('track_material', 20)->default('STEEL');
            $table->string('roller_coaster_type', 20)->default('SITDOWN');
            
            // Launch and train details
            $table->string('launch_type', 20)->default('CHAIN');
            $table->string('train_style')->default('');
            $table->unsignedInteger('trains_count')->nullable();
            $table->unsignedInteger('cars_per_train')->nullable();
            $table->unsignedInteger('seats_per_car')->nullable();
            
            // No timestamps needed as this table is coupled to rides table
            
            // Indexes
            $table->index('track_material');
            $table->index('roller_coaster_type');
            $table->index('launch_type');
        });
    }

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