<?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
    {
        Schema::table('work_orders', function (Blueprint $table) {
            $table->foreignId('production_line_id')->nullable()->after('bom_id')->constrained();
            $table->foreignId('machine_id')->nullable()->after('production_line_id')->constrained();
        });
    }

    public function down(): void
    {
        Schema::table('work_orders', function (Blueprint $table) {
            $table->dropForeign(['production_line_id']);
            $table->dropForeign(['machine_id']);
            $table->dropColumn(['production_line_id', 'machine_id']);
        });
    }
};
