<?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_order_material_inputs', function (Blueprint $table) {
            $table->string('bom_group_key')->nullable()->after('item_id')
                ->comment('BOM 그룹키 (같은 item_id의 다른 용도 구분, ex: itemId_category_partType)');

            $table->index(['work_order_item_id', 'bom_group_key'], 'idx_womi_item_bomgroup');
        });
    }

    public function down(): void
    {
        Schema::table('work_order_material_inputs', function (Blueprint $table) {
            $table->dropIndex('idx_womi_item_bomgroup');
            $table->dropColumn('bom_group_key');
        });
    }
};
