<?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('order_items', function (Blueprint $table) {
            $table->foreignId('order_node_id')
                ->nullable()
                ->after('order_id')
                ->comment('수주 노드 ID (order_nodes)');
            $table->index('order_node_id');
        });
    }

    public function down(): void
    {
        Schema::table('order_items', function (Blueprint $table) {
            $table->dropIndex(['order_node_id']);
            $table->dropColumn('order_node_id');
        });
    }
};
