<?php

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

return new class extends Migration
{
    /**
     * Remove o campo balance_after da tabela transactions
     * O saldo deve ser sempre calculado dinamicamente para evitar erros de cálculo
     */
    public function up(): void
    {
        Schema::table('transactions', function (Blueprint $table) {
            $table->dropColumn('balance_after');
        });
    }

    public function down(): void
    {
        Schema::table('transactions', function (Blueprint $table) {
            $table->decimal('balance_after', 15, 2)->nullable()->after('amount');
        });
    }
};
