<?php

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

/**
 * Supports the vendor-SLA re-confirmation flow: when the accept window lapses we
 * ask the customer to keep waiting (reconfirm_prompted_at + reconfirm_deadline)
 * rather than cancelling outright; timed_out flags items the vendor never
 * answered (feeds the vendor responsiveness score).
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('order_items', function (Blueprint $table) {
            $table->timestamp('reconfirm_prompted_at')->nullable()->after('sla_deadline');
            $table->timestamp('reconfirm_deadline')->nullable()->after('reconfirm_prompted_at');
            $table->boolean('timed_out')->default(false)->after('reconfirm_deadline');
        });
    }

    public function down(): void
    {
        Schema::table('order_items', function (Blueprint $table) {
            $table->dropColumn(['reconfirm_prompted_at', 'reconfirm_deadline', 'timed_out']);
        });
    }
};
