mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 05:51:09 -05:00
Refactor Location model to integrate PostGIS for spatial data, add legacy coordinate fields for compatibility, and enhance documentation for geocoding service implementation.
This commit is contained in:
@@ -24,9 +24,19 @@ return new class extends Migration
|
||||
$table->string('country');
|
||||
$table->string('postal_code')->nullable();
|
||||
|
||||
// Coordinates
|
||||
$table->decimal('latitude', 10, 8);
|
||||
$table->decimal('longitude', 11, 8);
|
||||
// Enable PostGIS extension if not enabled
|
||||
DB::statement('CREATE EXTENSION IF NOT EXISTS postgis');
|
||||
|
||||
// Location name and type
|
||||
$table->string('name')->nullable();
|
||||
$table->string('location_type', 50)->nullable();
|
||||
|
||||
// Legacy coordinate fields for backward compatibility
|
||||
$table->decimal('latitude', 9, 6)->nullable();
|
||||
$table->decimal('longitude', 9, 6)->nullable();
|
||||
|
||||
// Coordinates using PostGIS
|
||||
$table->point('coordinates')->spatialIndex();
|
||||
$table->decimal('elevation', 8, 2)->nullable();
|
||||
|
||||
// Additional details
|
||||
@@ -43,9 +53,10 @@ return new class extends Migration
|
||||
$table->timestamps();
|
||||
|
||||
// Indexes
|
||||
$table->index(['latitude', 'longitude']);
|
||||
$table->index(['country', 'state', 'city']);
|
||||
$table->index('postal_code');
|
||||
$table->index('name');
|
||||
$table->index('location_type');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user