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

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