<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
   // database/migrations/xxxx_xx_xx_create_alertas_table.php
    public function up()
        {
            Schema::create('alertas', function (Blueprint $table) {
                $table->id();
                $table->foreignId('user_id')->constrained()->onDelete('cascade');
                $table->foreignId('empresa_id')->nullable()->constrained()->onDelete('set null');
                $table->string('tipo')->default('panico');
                $table->text('mensaje')->nullable();
                $table->string('latitud')->nullable();
                $table->string('longitud')->nullable();
                $table->string('estado')->default('pendiente'); // pendiente, atendida, resuelta
                $table->timestamps();
            });
        }


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