<?php

declare(strict_types=1);

use App\Models\SupportRequest;
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::table('support_requests', function (Blueprint $table): void {
            $table->string('external_handoff_mode')
                ->default(SupportRequest::EXTERNAL_HANDOFF_MODE_INTERNAL_ONLY)
                ->after('context_envelope');
            $table->string('external_ticket_reference')->nullable()->after('external_handoff_mode');
            $table->text('external_ticket_url')->nullable()->after('external_ticket_reference');
            $table->text('external_handoff_failure_summary')->nullable()->after('external_ticket_url');
        });
    }

    public function down(): void
    {
        Schema::table('support_requests', function (Blueprint $table): void {
            $table->dropColumn([
                'external_handoff_mode',
                'external_ticket_reference',
                'external_ticket_url',
                'external_handoff_failure_summary',
            ]);
        });
    }
};
