<?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
    {
        // Cek dulu apakah kolom sudah ada, jika belum baru ditambahkan
        if (!Schema::hasColumn('fabrication_orders', 'actual_target_quantity')) {
            Schema::table('fabrication_orders', function (Blueprint $table) {
                $table->decimal('actual_target_quantity', 15, 2)->default(0)->after('target_quantity');
            });
        }
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('fabrication_orders', function (Blueprint $table) {
            $table->dropColumn('actual_target_quantity');
        });
    }
};