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

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

            $table->unsignedBigInteger('technician_consumable_id');

            $table->string('barcode_id');
            $table->string('material_name');

            $table->decimal('qty_used', 10, 2);
            $table->string('unit')->default('meter');

            $table->dateTime('used_at');

            $table->timestamps();

            $table->index('ticket_id');
            $table->index('user_id');
        });
    }

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