<?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('managed_environments', function (Blueprint $table) {
            $table->unsignedBigInteger('rbac_last_setup_by')->nullable()->after('rbac_last_checked_at');
            $table->timestamp('rbac_last_setup_at')->nullable()->after('rbac_last_setup_by');
            $table->json('rbac_canary_results')->nullable()->after('rbac_last_setup_at');
            $table->json('rbac_last_warnings')->nullable()->after('rbac_canary_results');
        });
    }

    public function down(): void
    {
        Schema::table('managed_environments', function (Blueprint $table) {
            $table->dropColumn([
                'rbac_last_setup_by',
                'rbac_last_setup_at',
                'rbac_canary_results',
                'rbac_last_warnings',
            ]);
        });
    }
};
