<?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('forecast_outcomes', function (Blueprint $table) {
            $table->date('forecast_for');
            $table->string('model_version', 64);
            $table->enum('predicted_class', ['rising', 'falling', 'flat']);
            $table->enum('actual_class', ['rising', 'falling', 'flat']);
            $table->boolean('correct');
            $table->unsignedSmallInteger('abs_error_pence')->comment('|predicted − actual|, in pence × 100');
            $table->dateTime('resolved_at');

            $table->primary(['forecast_for', 'model_version']);
            $table->index(['model_version', 'resolved_at']);
        });
    }

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