<?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('products', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('sku')->unique()->nullable(); // Código de barras o interno
            $table->text('description')->nullable();

            $table->decimal('price', 10, 2); // Precio venta
            $table->decimal('cost', 10, 2)->nullable(); // Costo (solo admin)
            
            $table->integer('stock_quantity')->default(0);
            $table->integer('min_stock_alert')->default(5); // Alerta

            $table->enum('type', ['bike', 'accessory', 'service']);
            $table->string('serial_number')->nullable(); // Solo para bicis
            
            $table->foreignId('suppliers_id')->constrained();
            $table->timestamps();
        });
    }

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