<?php

use App\Models\User;
use App\Support\InvestmentLedger;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{
    public function up(): void
    {
        User::query()
            ->select('id')
            ->orderBy('id')
            ->each(function (User $user): void {
                InvestmentLedger::syncLegacyReferralBalanceToWithdrawablePool($user);
            });
    }

    public function down(): void
    {
        // No reversible: el saldo ya formó parte del contenedor retirable del usuario.
    }
};
