<?php

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

/**
 * A distinct in-flight claim, separate from sent_at. claimed_at is set at
 * send-time by exactly one job (atomic conditional update) to dedup concurrent
 * copies; sent_at is set only on real delivery so a transport failure stays
 * retryable once the claim goes stale.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('maintenance_notifications', function (Blueprint $table) {
            $table->timestamp('claimed_at')->nullable()->after('sent_at');
        });
    }

    public function down(): void
    {
        Schema::table('maintenance_notifications', function (Blueprint $table) {
            $table->dropColumn('claimed_at');
        });
    }
};
