<?php

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

return new class extends Migration
{
    public function up(): void
    {
        if (! Schema::hasTable('wallet_ledgers')) {
            return;
        }

        if (DB::getDriverName() === 'mysql') {
            DB::statement("
                ALTER TABLE wallet_ledgers
                MODIFY COLUMN source ENUM('purchase','refund','monnify','paystack','admin_adjust','cashback','wallet_transfer') NOT NULL
            ");
        }
    }

    public function down(): void
    {
        if (! Schema::hasTable('wallet_ledgers')) {
            return;
        }

        if (DB::getDriverName() === 'mysql') {
            DB::statement("
                ALTER TABLE wallet_ledgers
                MODIFY COLUMN source ENUM('purchase','refund','monnify','paystack','admin_adjust','cashback') NOT NULL
            ");
        }
    }
};

