<?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('work_orders', function (Blueprint $t) {
            if (! Schema::hasColumn('work_orders', 'apply_margin')) {
                $t->boolean('apply_margin')->default(true)->after('override_margin_pct');
            }
        });
    }

    public function down(): void
    {
        Schema::table('work_orders', function (Blueprint $t) {
            if (Schema::hasColumn('work_orders', 'apply_margin')) {
                $t->dropColumn('apply_margin');
            }
        });
    }
};
