dumpsites table with both coordinates POINT and boundary_polygon
POLYGON (SRID 4326). Admin CRUD accepts boundary as a list of {lat,lng}
points; ring is auto-closed. Dumpsite::containsPoint() runs ST_Contains
for geofence checks (Module 10 will fire arrived_at_dumpsite from this).
dumpsite_releases schema in place — trip_id stays nullable bigint until
Module 10 adds the FK.
109 feature tests passing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
49 lines
1.7 KiB
PHP
49 lines
1.7 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
Schema::create('dumpsites', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->uuid('uuid')->unique();
|
|
$table->string('name', 191);
|
|
$table->string('code', 32)->unique();
|
|
$table->string('address_line', 255);
|
|
$table->foreignId('city_municipality_id')
|
|
->nullable()
|
|
->constrained('cities_municipalities')
|
|
->nullOnDelete();
|
|
$table->geometry('coordinates', subtype: 'point', srid: 4326);
|
|
$table->geometry('boundary_polygon', subtype: 'polygon', srid: 4326)->nullable();
|
|
$table->json('accepted_waste_types')->nullable();
|
|
$table->json('operating_hours')->nullable();
|
|
$table->unsignedInteger('capacity_tons')->nullable();
|
|
$table->string('contact_person', 191)->nullable();
|
|
$table->string('contact_phone', 32)->nullable();
|
|
$table->string('permit_number', 100)->nullable();
|
|
$table->enum('status', ['active', 'maintenance', 'closed'])
|
|
->default('active')
|
|
->index();
|
|
$table->timestamps();
|
|
$table->softDeletes();
|
|
|
|
$table->index(['city_municipality_id', 'status']);
|
|
});
|
|
|
|
DB::statement(
|
|
'ALTER TABLE dumpsites ADD SPATIAL INDEX dumpsites_coords_spx (coordinates)',
|
|
);
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('dumpsites');
|
|
}
|
|
};
|