Using Symfony 2.8.24, Doctrine 2 and Jsor's doctrine-postgis library, the latter to make Doctrine get along with spatial types like geometry, geography, etc.
So, I have a table with a column of type geometry(MultiPolygon, 3795)
, at least it is presented as so in pgAdmin III (I'm using OpenGeo's pgAdmin which includes the postgis extension, along with plpgsql)
I have the tables with the spatial info, so I created my entities from those tables, via doctrine:mapping:import
and doctrine:mapping:convert
commands, which indeed created the corresponding php classes without an issue.
THE PROBLEM came when I made some changes to other entities in my project, entities which did not even have spatial type attributes, after that I tried to "doctrine:schema:update" "--force"
to sync the database with my new changes and I get the error from the title
The geometry_type of a spatial column cannot be changed (Requested changing type from "MULTIPOLYGON" to "GEOMETRY" for column "geom" in table "X")
Fragment of the entity class as generated by the commands:
/**
* TableName
*
* @ORM\Table(name="TableName", indexes={@ORM\Index(name="sidx_table_name_geom", columns={"geom"})})
* @ORM\Entity
*/
class TableName {
/**
* @var integer
*
* @ORM\Column(name="gid", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="SEQUENCE")
* @ORM\SequenceGenerator(sequenceName="table_name_gid_seq", allocationSize=1, initialValue=1)
*/
private $gid;
/**
* @var MULTIPOLYGON
*
* @ORM\Column(name="geom", type="geometry", options={"geometry_type"="MULTIPOLYGON", "srid"=3795}, nullable=true)
*/
private $geom;
}
I tried to follow this solution in github to no avail, although it was exactly my situation.