<?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::create('store_requisition_items', function (Blueprint $table) {
            $table->id();
            $table->foreignId('store_requisition_id')->constrained()->cascadeOnDelete();
            $table->unsignedBigInteger('product_id');
            $table->decimal('requested_qty', 12, 2)->comment('需求數量');
            $table->decimal('approved_qty', 12, 2)->nullable()->comment('核准數量（審核時填入）');
            $table->text('remark')->nullable();
            $table->timestamps();

            $table->index('product_id');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('store_requisition_items');
    }
};
