<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('providers', function (Blueprint $table) {
            $table->string('idempotency_key')->nullable()->after('recipient_code');
        });

        Schema::table('payments', function (Blueprint $table) {
            $table->string('idempotency_key')->nullable()->after('gateway_code');
        });

        Schema::table('clients', function (Blueprint $table) {
            $table->string('idempotency_key')->nullable()->after('external_customer_code');
        });

        Schema::table('client_payment_methods', function (Blueprint $table) {
            $table->string('idempotency_key')->nullable()->after('gateway_card_id');
        });
    }

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

        Schema::table('payments', function (Blueprint $table) {
            $table->dropColumn('idempotency_key');
        });

        Schema::table('clients', function (Blueprint $table) {
            $table->dropColumn('idempotency_key');
        });

        Schema::table('client_payment_methods', function (Blueprint $table) {
            $table->dropColumn('idempotency_key');
        });
    }
};
