<?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('material_movements', function (Blueprint $table) {
            $table->id();

            $table->string('barcode_id');

            $table->unsignedBigInteger('user_id')->nullable();
            $table->unsignedBigInteger('from_user_id')->nullable();
            $table->unsignedBigInteger('to_user_id')->nullable();

            $table->unsignedBigInteger('ticket_id')->nullable();

            $table->enum('movement_type', [
                'assign',
                'transfer',
                'use',
                'return',
                'lost',
                'damaged'
            ]);

            $table->decimal('qty', 10, 2)->nullable();

            $table->text('description')->nullable();

            $table->unsignedBigInteger('created_by')->nullable();

            $table->dateTime('created_at');
        });
    }

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