<?php

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

/**
 * The per-product expiry switch behind FEFO/FIFO stock picking.
 *
 * A product that needs expiry management (perishables) carries
 * `is_expiry_tracked = 1`: its GRN lines must strictly capture an expiry
 * date, and barcode-driven POS sales take stock FEFO (soonest expiry first).
 * Products without the flag are received without an expiry field at all and
 * their lots sell FIFO (oldest receipt first).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('products', function (Blueprint $table) {
            $table->boolean('is_expiry_tracked')->default(false)->after('is_serial_tracked');
        });
    }

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