<?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_ledger_entries')) {
            DB::table('wallet_ledger_entries')->where('currency', 'USD')->update(['currency' => 'INR']);
        }

        if (Schema::hasTable('settings')) {
            DB::table('settings')->where('key', 'app.currency')->update(['value' => 'INR']);
        }
    }

    public function down(): void
    {
        if (Schema::hasTable('wallet_ledger_entries')) {
            DB::table('wallet_ledger_entries')->where('currency', 'INR')->update(['currency' => 'USD']);
        }

        if (Schema::hasTable('settings')) {
            DB::table('settings')->where('key', 'app.currency')->update(['value' => 'USD']);
        }
    }
};
