jsor / doctrine-postgis

Spatial and Geographic Data with PostGIS and Doctrine.
MIT License
209 stars 50 forks source link

Issue with `validate` doctrine command #31

Closed Atala closed 7 years ago

Atala commented 7 years ago

Hey,

I am not sure if it's the correct place to ask for this, so correct me if I am wrong.

When using bin/console doctrine:schema:update to validate the schema, doctrine always returns [Database] FAIL - The database schema is not in sync with the current mapping file .

If I run bin/console doctrine:schema:update --dump-sql to see what's wrong, I always get the following COMMENT ON COLUMN address.geo IS '(DC2Type:geography)'; .

Not sure if it's an issue with doctrine or doctrine-postgis - could you help me on this?

jsor commented 7 years ago

Could you provide a little bit background of your setup, at best a minimal reproducible test case? Are you using it with a framework, eg. Symfony?

reskume commented 7 years ago

Hi!

I'm seeing this error too. I created a repo to showcase the issue with Symfony 3.3 at https://github.com/reskume/doctrine-postgis-31. If i run:

php bin/console doctrine:schema:drop --force && php bin/console doctrine:schema:create && php bin/console doctrine:schema:validate

the output is

Dropping database schema...
Database schema dropped successfully!
ATTENTION: This operation should not be executed in a production environment.

Creating database schema...
Database schema created successfully!
[Mapping]  OK - The mapping files are correct.
[Database] FAIL - The database schema is not in sync with the current mapping file.

The dumped SQL from schema update tool is also, as mentioned above

COMMENT ON COLUMN poi.geometry IS '(DC2Type:geometry)';

jsor commented 7 years ago

@reskume Thanks for the setup, it helped tracking it down. You need to explicitly define the types as not commented in config.yml

doctrine:
    dbal:
        types:
            geography:
                class: 'Jsor\Doctrine\PostGIS\Types\GeographyType'
                commented: false
            geometry:
                class: 'Jsor\Doctrine\PostGIS\Types\GeometryType'
                commented: false
            raster:
                class: 'Jsor\Doctrine\PostGIS\Types\RasterType'
                commented: false

I'm going to update the documentation.

jsor commented 7 years ago

Btw, it is usually not required to manually register the DBAL types in the config und you can also just remove it.

reskume commented 7 years ago

Thanks @jsor for the quick workaround!

Atala commented 7 years ago

@jsor is this a workaround and you (or doctrine maintainers) are going to issue a permanent fix?

Thanks for your quick answer!

jsor commented 7 years ago

No, this is just the correct way to configure the types in Symfony. For whatever reason, Symfony overwrites the commented configuration of the registered types.

But as i said, you usually don't need to register the types manually. I've update the section in the README in 9bfbcc6072067d0788fed476de8866d2a6501047.

https://github.com/jsor/doctrine-postgis/blob/9bfbcc6072067d0788fed476de8866d2a6501047/README.md#L67-L84

jsor commented 7 years ago

I think this issues has been resolved. Feel free to reopen if needed.