<?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
    {
        if (! Schema::hasTable('baseline_profiles')) {
            return;
        }

        Schema::table('baseline_profiles', function (Blueprint $table): void {
            if (! Schema::hasColumn('baseline_profiles', 'capture_mode')) {
                $table->string('capture_mode')->default('opportunistic')->after('status');
            }
        });
    }

    public function down(): void
    {
        if (! Schema::hasTable('baseline_profiles')) {
            return;
        }

        Schema::table('baseline_profiles', function (Blueprint $table): void {
            if (Schema::hasColumn('baseline_profiles', 'capture_mode')) {
                $table->dropColumn('capture_mode');
            }
        });
    }
};
