<?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::create('station_prices_archive', function (Blueprint $table): void {
            $table->bigIncrements('id');
            $table->string('station_id', 64);
            $table->string('fuel_type', 20);
            $table->unsignedSmallInteger('price_pence');
            $table->dateTime('price_effective_at');
            $table->dateTime('price_reported_at');
            $table->dateTime('recorded_at');

            $table->index(['station_id', 'fuel_type', 'price_effective_at'], 'spa_station_fuel_effective_idx');
            $table->index('price_effective_at', 'spa_price_effective_at_idx');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('station_prices_archive');
    }
};
