<?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('stock_movements', function (Blueprint $table) {
            $table->id();
            $table->foreignId('consignment_id')
                  ->constrained()
                  ->cascadeOnDelete();
            $table->enum('type', ['IN', 'OUT']);
            $table->string('receipt_number')->nullable();
            $table->string('collected_by')->nullable();
            $table->text('notes')->nullable();
            $table->foreignId('moved_by')
                  ->constrained('users')
                  ->restrictOnDelete();
            $table->timestamp('moved_at');
            $table->timestamps();
        });
    }

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