longitude-one / doctrine-spatial

Doctrine extension to persist spatial data objects.
https://lo-doctrine-spatial.readthedocs.io/en/latest/
MIT License
69 stars 21 forks source link

Migration drops Postgis Sequences #108

Closed ThomasBerends closed 6 days ago

ThomasBerends commented 3 months ago

Hi. I'm probably doing something wrong myself, but here's my steps:

For a database with postgis, I'm using the official docker image postgis/postgis:16-master.

I've installed longitude-one/doctrine-spatial (version 5.0.2) and I've added the following to my config:

doctrine:
    dbal:
        types:
            geography: LongitudeOne\Spatial\DBAL\Types\GeographyType
            point: LongitudeOne\Spatial\DBAL\Types\Geography\PointType

This works as expected.

When I run php bin/console make:migration, it creates a migration succesfully, however, it contains this:

        $this->addSql('DROP SEQUENCE topology.topology_id_seq CASCADE');
        $this->addSql('DROP SEQUENCE tiger.county_gid_seq CASCADE');
        $this->addSql('DROP SEQUENCE tiger.state_gid_seq CASCADE');
        $this->addSql('DROP SEQUENCE tiger.place_gid_seq CASCADE');
        $this->addSql('DROP SEQUENCE tiger.cousub_gid_seq CASCADE');
        $this->addSql('DROP SEQUENCE tiger.edges_gid_seq CASCADE');
        $this->addSql('DROP SEQUENCE tiger.addrfeat_gid_seq CASCADE');
        $this->addSql('DROP SEQUENCE tiger.faces_gid_seq CASCADE');
        $this->addSql('DROP SEQUENCE tiger.featnames_gid_seq CASCADE');
        $this->addSql('DROP SEQUENCE tiger.addr_gid_seq CASCADE');
        $this->addSql('DROP SEQUENCE tiger.zcta5_gid_seq CASCADE');
        $this->addSql('DROP SEQUENCE tiger.tract_gid_seq CASCADE');
        $this->addSql('DROP SEQUENCE tiger.tabblock_gid_seq CASCADE');
        $this->addSql('DROP SEQUENCE tiger.bg_gid_seq CASCADE');
        $this->addSql('DROP SEQUENCE tiger.pagc_gaz_id_seq CASCADE');
        $this->addSql('DROP SEQUENCE tiger.pagc_lex_id_seq CASCADE');
        $this->addSql('DROP SEQUENCE tiger.pagc_rules_id_seq CASCADE');

The same issue is described in this blog here, and while the problem seems correct, I feel the solution provided there is not the correct one since I expect this package to have a solution to this.

Is there something I'm missing?

Alexandre-T commented 2 months ago

Hello,

Thank you for your message. What a surprise to discover tutorials about this package ! This issue doesn't come from Postgis, nor this library, nor doctrine-migration. It sounds like a misunderstood about the doctrine-migration package.

As far as I remember, you only have to tell doctrine migration to ignore the tiger schema. I didn't check the following code, but it should contain the solution.

doctrine_migrations:
    # ... autres configurations
    migrations_namespace: App\DoctrineMigrations
    # Exclure le schéma "tiger"
    schema_filter: '~^(?!tiger)~'

I'll appreciate if you could test it and report us if it solve your issue.

ThomasBerends commented 2 months ago

It worked like this:

doctrine:
    dbal:
        schema_filter: '~^(?!tiger)~'

Would it be an idea to add this to the documentation? I can make a PR, but not sure if it's desired or not.

Alexandre-T commented 2 months ago

Thank you for your feedback !

Even if it's more an issue linked to doctrine-migration, IMHO it could be great to add your answer to the documentation. Feel free to make a PR ! Thanks again !