<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up()
    {
        Schema::create('ajustes', function (Blueprint $table) {
            $table->id();
            $table->string('referencia_type');
            $table->unsignedBigInteger('referencia_id');
            $table->unsignedBigInteger('user_id')->nullable();
            $table->string('tipo')->default('arreglo');
            $table->integer('cantidad')->default(0);
            $table->text('notas')->nullable();
            $table->timestamps();

            $table->index(['referencia_type', 'referencia_id']);
        });
    }

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