<?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('moraqebat_checklists')) {
            return;
        }

        if (Schema::hasColumn('moraqebat_checklists', 'technical_officer_note')) {
            return;
        }

        Schema::table('moraqebat_checklists', function (Blueprint $table) {
            $table->text('technical_officer_note')->nullable()->after('is_repair_required');
        });
    }

    public function down(): void
    {
        if (! Schema::hasTable('moraqebat_checklists') || ! Schema::hasColumn('moraqebat_checklists', 'technical_officer_note')) {
            return;
        }

        Schema::table('moraqebat_checklists', function (Blueprint $table) {
            $table->dropColumn('technical_officer_note');
        });
    }
};
