<?php

declare(strict_types=1);

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_tickets', function (Blueprint $table): void {
            // Drop unique index first, then column
            $table->dropUnique(['supportpal_ticket_id']);
            $table->dropColumn('supportpal_ticket_id');
        });
    }

    public function down(): void
    {
        Schema::table('support_tickets', function (Blueprint $table): void {
            $table->unsignedBigInteger('supportpal_ticket_id')->nullable()->unique()->after('user_id');
        });
    }
};
