<?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('vehiculos', function (Blueprint $table) {
            $table->id();
            $table->foreignId('tenant_id')->constrained()->onDelete('cascade');
            $table->string('placa')->nullable();
            $table->string('marca')->nullable();
            $table->string('modelo')->nullable();
            $table->integer('anio')->nullable();
            $table->string('color')->nullable();
            $table->enum('tipo', ['liviano', 'pesado'])->default('liviano');
            $table->decimal('valor_asegurado', 15, 2)->nullable();
            $table->text('extras')->nullable();
            $table->integer('kilometraje_actual')->nullable();
            $table->timestamps();

            $table->unique(['tenant_id', 'placa']);
        });
    }

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