Using Postgres with the Postgis extension to integrate GeoData / GIS functionality in your project is not natively supported by Doctrine and Doctrine migrations.
First you have to add the extension to Postgres, even if you use the Postgis docker image like postgis/postgis:14-3.3-alpine
.
So add this SQL statement to the up method of your first migration:
$this->addSql('CREATE EXTENSION IF NOT EXISTS postgis;');
and the DROP statement for the extension to the down method:
$this->addSql('DROP EXTENSION postgis;');
Now, when using Doctrine with Postgres and Postgis extension, migrations still behave a bit odd and try to remove Sequences created by Postgis, because Doctrine migrations does not take Postgis extension’ s built-in Sequences into account.
Continue reading “Doctrine migrations and Postgis”