<?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('olts', function (Blueprint $table) {
            $table->uuid('gateway_uuid')->nullable()->unique()->after('id');
            $table->string('gateway_status', 30)->nullable()->index()->after('connected');
            $table->json('gateway_snapshot')->nullable()->after('gateway_status');
            $table->text('gateway_error')->nullable()->after('gateway_snapshot');
            $table->timestamp('gateway_synced_at')->nullable()->after('gateway_error');
        });
    }

    public function down(): void
    {
        Schema::table('olts', function (Blueprint $table) {
            $table->dropUnique(['gateway_uuid']);
            $table->dropIndex(['gateway_status']);
            $table->dropColumn(['gateway_uuid', 'gateway_status', 'gateway_snapshot', 'gateway_error', 'gateway_synced_at']);
        });
    }
};
