<?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('stock', function (Blueprint $table) {
            $table->id();
            $table->foreignId('magasin_id')->constrained('magasins')->cascadeOnDelete();
            $table->foreignId('produit_id')->constrained('produits')->cascadeOnDelete();
            $table->unsignedInteger('quantite')->default(0);
            $table->unsignedInteger('seuil_alerte')->default(0);
            $table->softDeletes();
            $table->timestamps();

            $table->unique(['magasin_id', 'produit_id']);
        });
    }

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