<?php

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

/**
 * Custom-method tender details (see PaymentMethodsRelationManager's `fields`
 * config) captured at advance-entry time, so a custom method's required
 * fields travel with the payment and are replayed as real split
 * `custom_fields` by SalesOrderService::convertToInvoice().
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('sales_order_payments', function (Blueprint $table) {
            $table->json('custom_fields')->nullable()->after('cheque_date');
        });
    }

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