<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('transactions', function (Blueprint $table) {
            // Retry tracking
            $table->integer('processing_attempts')->default(0)->after('status');
            $table->timestamp('last_processed_at')->nullable()->after('processing_attempts');
            $table->timestamp('completed_at')->nullable()->after('last_processed_at');
            $table->timestamp('failed_at')->nullable()->after('completed_at');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('transactions', function (Blueprint $table) {
            $table->dropColumn([
                'processing_attempts',
                'last_processed_at',
                'completed_at',
                'failed_at'
            ]);
        });
    }
};
