<?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::create('manufacturing_bom_steps', function (Blueprint $table) {
            $table->id();
            $table->foreignId('manufacturing_bom_id')->constrained('manufacturing_boms')->cascadeOnDelete();
            $table->string('step_name');
            $table->text('instruction')->nullable();
            $table->integer('sequence_order');
            $table->timestamps();

            $table->index(['manufacturing_bom_id', 'sequence_order'], 'mb_steps_bom_seq_idx');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('manufacturing_bom_steps');
    }
};
