<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('risk_assessments', function (Blueprint $table) {
            if (!Schema::hasColumn('risk_assessments', 'likelihood')) {
                $table->enum('likelihood', ['low', 'medium', 'high'])->nullable()->after('risk_level');
            }
            if (!Schema::hasColumn('risk_assessments', 'impact')) {
                $table->enum('impact', ['low', 'medium', 'high'])->nullable()->after('likelihood');
            }
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('risk_assessments', function (Blueprint $table) {
            if (Schema::hasColumn('risk_assessments', 'impact')) {
                $table->dropColumn('impact');
            }
            if (Schema::hasColumn('risk_assessments', 'likelihood')) {
                $table->dropColumn('likelihood');
            }
        });
    }
};
