<?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('warehouse_items', function (Blueprint $table) {
            $table->id();
            $table->string('nama');
            $table->string('satuan', 50);
            $table->string('kategori', 100)->nullable();
            $table->decimal('harga_beli', 15, 2)->default(0);
            $table->decimal('stok_awal', 15, 2)->default(0);
            $table->decimal('stok_minimum', 15, 2)->default(0);
            $table->boolean('is_active')->default(true);
            $table->timestamps();

            $table->index(['nama', 'kategori', 'is_active']);
        });
    }

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