<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Offline lat/long -> country resolution: a spatial table of country boundary polygons queried with
* ST_Contains, replacing the external geokeo reverse-geocoder for country assignment.
*
* Seed it after migrating with: bin/console app:geo:seed-country-boundaries
*/
final class Version20260604130000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add country_boundaries spatial table for offline lat/long -> country resolution.';
}
public function up(Schema $schema): void
{
// SRID 0 (planar): boundaries and query points are plain long/lat Cartesian, which avoids
// the EPSG:4326 axis-order pitfall and is exact enough for point-in-polygon country lookup.
$this->addSql(<<<'SQL'
CREATE TABLE country_boundaries (
id INT UNSIGNED AUTO_INCREMENT NOT NULL,
iso_code VARCHAR(2) NOT NULL,
geom GEOMETRY NOT NULL SRID 0,
PRIMARY KEY(id),
INDEX idx_country_boundaries_iso (iso_code),
SPATIAL INDEX idx_country_boundaries_geom (geom)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
SQL);
}
public function down(Schema $schema): void
{
$this->addSql('DROP TABLE country_boundaries');
}
}