<?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('stocks', function (Blueprint $table) {
            $table->id();
            $table->string('reference')->unique();
            $table->string('name');
            $table->string('description')->nullable();
            $table->integer('actual_quantity'); // stock actuel
            $table->integer('quantity_available'); // quantité disponible
            $table->integer('reserved_quantity'); // quantité reservée
            $table->foreignId('product_id')->constrained('products')->cascadeOnDelete('set null');
            $table->foreignId('user_id')->constrained('users')->cascadeOnDelete('set null');
            $table->timestamps();
        });
    }

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