Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The geometry_type of a spatial column cannot be changed Requested changing type from "POINT" to "GEOMETRY" #62

Closed
sasa-b opened this issue Aug 10, 2023 · 0 comments

Comments

@sasa-b
Copy link
Contributor

sasa-b commented Aug 10, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant