<?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('move_order_items', function (Blueprint $table) {
            $table->id();
            $table->foreignId('move_order_id')
                ->constrained()
                ->cascadeOnDelete();
            $table->foreignId('item_id')->constrained();
            $table->string('item_code_snapshot')->nullable();
            $table->string('item_name_snapshot')->nullable();
            $table->decimal('requested_qty', 10, 3);
            $table->decimal('released_qty', 10, 3)->default(0);
            $table->decimal('remaining_qty', 10, 3)->default(0);
            $table->softDeletes();
            $table->timestamps();
        });
    }

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