<?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('findings', function (Blueprint $table): void {
            $table->string('source')->nullable()->after('finding_type');
            $table->index(['managed_environment_id', 'source']);
        });
    }

    public function down(): void
    {
        Schema::table('findings', function (Blueprint $table): void {
            $table->dropIndex(['managed_environment_id', 'source']);
            $table->dropColumn('source');
        });
    }
};
