<?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::table('batch_kpi_snapshots', function (Blueprint $table) {
            $table->unsignedInteger('days_since_last_split')->nullable()->after('weight_spread_g');
            $table->decimal('post_split_biomass_gain_kg', 12, 2)->nullable()->after('days_since_last_split');
            $table->decimal('post_split_feed_kg', 12, 3)->nullable()->after('post_split_biomass_gain_kg');
            $table->decimal('post_split_fcr_real', 12, 3)->nullable()->after('post_split_feed_kg');
            $table->decimal('stage_biomass_gain_kg', 12, 2)->nullable()->after('post_split_fcr_real');
            $table->decimal('stage_feed_kg', 12, 3)->nullable()->after('stage_biomass_gain_kg');
            $table->decimal('stage_fcr_real', 12, 3)->nullable()->after('stage_feed_kg');
        });
    }

    public function down(): void
    {
        Schema::table('batch_kpi_snapshots', function (Blueprint $table) {
            $table->dropColumn([
                'days_since_last_split',
                'post_split_biomass_gain_kg',
                'post_split_feed_kg',
                'post_split_fcr_real',
                'stage_biomass_gain_kg',
                'stage_feed_kg',
                'stage_fcr_real',
            ]);
        });
    }
};
