<?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('recipient_id')->nullable()->unique()->after('profile_media_id');
            $table->string('recipient_name')->nullable()->after('recipient_id');
            $table->string('recipient_email')->nullable()->after('recipient_name');
            $table->text('recipient_description')->nullable()->after('recipient_email');
            $table->string('recipient_document')->nullable()->after('recipient_description');
            $table->string('recipient_type')->nullable()->after('recipient_document');
            $table->string('recipient_code')->nullable()->after('recipient_type');
            $table->string('recipient_payment_mode')->nullable()->after('recipient_code');

            $table->json('recipient_default_bank_account')->nullable()->after('recipient_payment_mode');
            $table->json('recipient_transfer_settings')->nullable()->after('recipient_default_bank_account');
            $table->json('recipient_automatic_anticipation_settings')->nullable()->after('recipient_transfer_settings');
            $table->json('recipient_metadata')->nullable()->after('recipient_automatic_anticipation_settings');
        });
    }

    public function down(): void
    {
        Schema::table('providers', function (Blueprint $table) {
            $table->dropUnique('providers_recipient_id_unique');
            $table->dropColumn([
                'recipient_id',
                'recipient_name',
                'recipient_email',
                'recipient_description',
                'recipient_document',
                'recipient_type',
                'recipient_code',
                'recipient_payment_mode',
                'recipient_default_bank_account',
                'recipient_transfer_settings',
                'recipient_automatic_anticipation_settings',
                'recipient_metadata',
            ]);
        });
    }
};
