<?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('registros_salidas', function (Blueprint $table) {
            $table->bigIncrements('id_salida');
            $table->unsignedInteger('id_manguera');
            $table->unsignedInteger('id_usuario');
            $table->dateTime('fecha_inicio');
            $table->dateTime('fecha_registro')->useCurrent();
            $table->boolean('estado')->default(true);
            $table->dateTime('fecha_fin')->nullable();
            $table->decimal('galones', 10, 3);
            $table->decimal('precio_galon', 10, 2);
            $table->decimal('total', 12, 2);
            $table->string('placa_vehiculo', 20)->nullable();
            $table->string('observaciones', 250)->nullable();

            $table->foreign('id_manguera')->references('id_manguera')->on('mangueras')->cascadeOnDelete();
            $table->foreign('id_usuario')->references('id_usuario')->on('usuarios')->cascadeOnDelete();
        });
    }

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