<?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::table('production_batches', function (Blueprint $table) {
            // Add weight-based tracking (grams)
            $table->decimal('total_weight_grams', 10, 2)->nullable()->after('batch_size');
            $table->decimal('remaining_weight_grams', 10, 2)->nullable()->after('total_weight_grams');
            $table->decimal('sold_weight_grams', 10, 2)->default(0)->after('remaining_weight_grams');
            $table->decimal('wasted_weight_grams', 10, 2)->default(0)->after('sold_weight_grams');

            // Keep existing scoop tracking for backward compatibility
            // total_scoops, remaining_scoops, sold_scoops, wasted_scoops remain unchanged
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('production_batches', function (Blueprint $table) {
            $table->dropColumn([
                'total_weight_grams',
                'remaining_weight_grams',
                'sold_weight_grams',
                'wasted_weight_grams'
            ]);
        });
    }
};
