<?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->string('batch_status', 20)->default('active')->after('tank_id');
            $table->date('cycle_closed_at')->nullable()->after('capital_locked_days');
            $table->decimal('harvest_completion_pct', 12, 2)->nullable()->after('cycle_closed_at');
            $table->decimal('sales_realization_pct', 12, 2)->nullable()->after('harvest_completion_pct');
            $table->boolean('cycle_closure_ready')->default(false)->after('sales_realization_pct');
            $table->string('cycle_closure_state', 20)->default('OPEN')->after('cycle_closure_ready');
        });
    }

    public function down(): void
    {
        Schema::table('batch_kpi_snapshots', function (Blueprint $table) {
            $table->dropColumn([
                'batch_status',
                'cycle_closed_at',
                'harvest_completion_pct',
                'sales_realization_pct',
                'cycle_closure_ready',
                'cycle_closure_state',
            ]);
        });
    }
};
