<?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('airtime_to_cash_requests', function (Blueprint $table) {
            $table->enum('payout_destination', ['wallet', 'bank'])->default('wallet')->after('sender_phone');
            $table->string('bank_name', 120)->nullable()->after('payout_destination');
            $table->string('bank_account_number', 20)->nullable()->after('bank_name');
            $table->string('bank_account_name', 191)->nullable()->after('bank_account_number');

            $table->index(['payout_destination', 'status'], 'atc_payout_status_idx');
        });
    }

    public function down(): void
    {
        Schema::table('airtime_to_cash_requests', function (Blueprint $table) {
            $table->dropIndex('atc_payout_status_idx');
            $table->dropColumn([
                'payout_destination',
                'bank_name',
                'bank_account_number',
                'bank_account_name',
            ]);
        });
    }
};
