<?php

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

/**
 * Phase 4a of the lot-pricing migration (see docs/migration-plan.md or the
 * spec in docs/): nothing writes products.sale_price / products.purchase_price
 * anymore — GrnService::syncProductPricing() is gone and every read path
 * prices from the receipt lot. The columns stay (the destructive migration
 * drops them last), but nothing may require them, so they become nullable.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('products', function (Blueprint $table): void {
            $table->decimal('sale_price', 12, 2)->nullable()->change();
        });
    }

    public function down(): void
    {
        Schema::table('products', function (Blueprint $table): void {
            $table->decimal('sale_price', 12, 2)->nullable(false)->change();
        });
    }
};
