<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

/**
 * Declares whether a product's stock is serial-tracked: when a product is
 * flagged, confirming a GRN for it REQUIRES one serial number per unit
 * received (GrnService::confirm). The flag is the intent to capture serials —
 * which serials exist stays data-driven, so lots received before the flag
 * (or for products that were never flagged) keep selling normally.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('products', function (Blueprint $table): void {
            $table->boolean('is_serial_tracked')->default(false)->after('is_active');
        });
    }

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