<?php

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

return new class extends Migration
{
    public function up()
    {
        Schema::table('emails_queued', function (Blueprint $table) {
            $table->dateTime('failed_at')->nullable()->after('sent_at');
            $table->text('failure_reason')->nullable()->after('failed_at');
            $table->unsignedSmallInteger('attempts')->default(0)->after('failure_reason');
        });
    }

    public function down()
    {
        Schema::table('emails_queued', function (Blueprint $table) {
            $table->dropColumn(['failed_at', 'failure_reason', 'attempts']);
        });
    }
};
