<?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::create('transacoes', function (Blueprint $table) {
            $table->id();
            $table->foreignId('notificacao_id')->constrained('notificacoes')->onDelete('cascade');
            $table->string('order_id')->unique();
            $table->enum('status_envio', ['pendente', 'waiting_payment', 'paid', 'erro']);
            $table->boolean('sera_aprovada');
            $table->integer('tempo_disparo_segundos');
            $table->timestamp('enviada_em')->nullable();
            $table->timestamp('aprovada_em')->nullable();
            $table->text('resposta_api')->nullable();
            $table->text('erro')->nullable();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('transacoes');
    }
};
