<?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('upwork_earnings', function (Blueprint $table) {
            // Cuenta destino para retiros (Payoneer, Airtm/ACH, etc.)
            $table->foreignId('account_id')
                  ->nullable()
                  ->after('sale_id')
                  ->constrained()
                  ->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('upwork_earnings', function (Blueprint $table) {
            $table->dropForeignIdFor(\App\Models\Account::class);
            $table->dropColumn('account_id');
        });
    }
};
