doctrine-postgis
doctrine-postgis copied to clipboard
The geometry_type of a spatial column cannot be changed Requested changing type from "POINT" to "GEOMETRY"
Hi there, I started getting this error when I run bin/console doctrine:migrations:diff
even though I haven't made any changes to the entity and table that are causing this issue.
In DBALSchemaEventSubscriber.php line 157:
The geometry_type of a spatial column cannot be changed (Requested changing type from "POINT" to "GEOMETRY" for column "coordinates" in table "main.locations")
What I did do is frequently update composer packages so I'm suspecting it might be happening only in the newer versions, these are the versions from my composer.lock:
"doctrine/orm": "2.16.1",
"jsor/doctrine-postgis": "^2.2"
I'm using this inside of a Symfony app if that adds more context.
This is my doctrine mapping which hasn't changed since adding this amazing package.
#[ORM\Column(type: PostGISType::GEOGRAPHY, options: ['geometry_type' => 'POINT', 'srid' => 4326])]
private string $coordinates;
This is what I get when I dump the new column in DBALSchemaEventSubscriber.php line 157:
^ Doctrine\DBAL\Schema\Column^ {#2159
#_name: "coordinates"
#_namespace: null
#_quoted: false
#_type: Jsor\Doctrine\PostGIS\Types\GeographyType^ {#279}
#_length: null
#_precision: 10
#_scale: 0
#_unsigned: false
#_fixed: false
#_notnull: true
#_default: null
#_autoincrement: false
#_platformOptions: array:2 [
"geometry_type" => "POINT"
"srid" => 4326
]
#_columnDefinition: null
#_comment: null
#_customSchemaOptions: array:2 [
"geometry_type" => "GEOMETRY"
"srid" => 4326
]
}
And this is what I get for the old column:
^ Doctrine\DBAL\Schema\Column^ {#923
#_name: "coordinates"
#_namespace: null
#_quoted: false
#_type: Jsor\Doctrine\PostGIS\Types\GeographyType^ {#279}
#_length: null
#_precision: 10
#_scale: 0
#_unsigned: false
#_fixed: false
#_notnull: true
#_default: null
#_autoincrement: false
#_platformOptions: []
#_columnDefinition: null
#_comment: null
#_customSchemaOptions: array:2 [
"geometry_type" => "POINT"
"srid" => 4326
]
}
As you can see the _customSchemaOptions
don't match for some reason. When I go to the \Doctrine\DBAL\Schema\Column
class I see that the _customSchemaOptions
has been deprecated, so I don't know if that could be potentially related to the issue.
/**
* @deprecated Use {@link $_platformOptions} instead
*
* @var mixed[]
*/
protected $_customSchemaOptions = [];
Another way to verify the issue is when you drop the database and try to recreate the diff, in that case, this error won't happen but the newly generated migration won't match it will look like this coordinates geography(GEOMETRY, 4326)