<?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('saved_locations', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('passenger_id');
            $table->string('label', 50)->nullable();
            $table->string('address', 500);
            $table->string('city', 100)->nullable();
            $table->decimal('latitude', 10, 8)->nullable();
            $table->decimal('longitude', 11, 8)->nullable();
            $table->timestamps();
            
            $table->foreign('passenger_id')->references('id')->on('passengers')->onDelete('cascade');
            $table->index('passenger_id');
        });
    }

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