<?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('products', function (Blueprint $table) {
            // true  → product requires an active production batch before it shows available in POS
            // false → product is always available in POS (made-to-order, toppings, sauces, etc.)
            $table->boolean('requires_production')->default(false)->after('is_active');
        });

        // Seed: ice cream (max_scoops > 0) historically meant production-tracked
        DB::table('products')->where('max_scoops', '>', 0)->update(['requires_production' => true]);
    }

    public function down(): void
    {
        Schema::table('products', function (Blueprint $table) {
            $table->dropColumn('requires_production');
        });
    }
};
