<?php

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('webhook_events', function (Blueprint $table): void {
            $table->string('event_id', 120)->nullable()->after('provider');
            $table->json('headers')->nullable()->after('payload');
            $table->index(['provider', 'event_id']);
        });
    }

    public function down(): void
    {
        Schema::table('webhook_events', function (Blueprint $table): void {
            $table->dropIndex(['provider', 'event_id']);
            $table->dropColumn('event_id');
            $table->dropColumn('headers');
        });
    }
};
