DBAL-903: php app/console doctrine:migration:diff generates redundant sql queries for postgres #2146

Closed
doctrinebot opened this Issue May 12, 2014 · 9 comments

5 participants

@doctrinebot

Jira issue originally created by user hanovruslan:

php app/console doctrine:migration:diff

generates redundant sql queries for postgres

symfony 2.4.2,
postgres 9.3
doctrine/orm: ~2.2,>=2.2.3
doctrine/doctrine-bundle: 1.2.*
doctrine/migrations: dev-master
doctrine/doctrine-migrations-bundle: dev-master

    public function up(Schema $schema)
    {

        $this->abortIf($this->connection->getDatabasePlatform()->getName() != "postgresql", "Migration can only be executed safely on 'postgresql'.");

        $this->addSql("DROP SEQUENCE acl*classes_id*seq1 CASCADE");
        $this->addSql("DROP SEQUENCE acl*security_identities_id*seq1 CASCADE");
        $this->addSql("DROP SEQUENCE acl*object_identities_id*seq1 CASCADE");
        $this->addSql("DROP SEQUENCE acl*entries_id*seq1 CASCADE");
    }

    public function down(Schema $schema)
    {

        $this->abortIf($this->connection->getDatabasePlatform()->getName() != "postgresql", "Migration can only be executed safely on 'postgresql'.");

        $this->addSql("CREATE SEQUENCE acl*classes_id*seq INCREMENT BY 1 MINVALUE 1 START 1");
        $this->addSql("CREATE SEQUENCE acl*security_identities_id*seq INCREMENT BY 1 MINVALUE 1 START 1");
        $this->addSql("CREATE SEQUENCE acl*object_identities_id*seq INCREMENT BY 1 MINVALUE 1 START 1");
        $this->addSql("CREATE SEQUENCE acl*entries_id*seq INCREMENT BY 1 MINVALUE 1 START 1");
        $this->addSql("CREATE SEQUENCE acl*classes_id*seq1 INCREMENT BY 1 MINVALUE 1 START 1");
        $this->addSql("CREATE SEQUENCE acl*security_identities_id*seq1 INCREMENT BY 1 MINVALUE 1 START 1");
        $this->addSql("CREATE SEQUENCE acl*object_identities_id*seq1 INCREMENT BY 1 MINVALUE 1 START 1");
        $this->addSql("CREATE SEQUENCE acl*entries_id*seq1 INCREMENT BY 1 MINVALUE 1 START 1");
    }
@doctrinebot

Comment created by @deeky666:

Doctrine ORM 2.2.x is EOL and won't receive any updates anymore. Please consider upgrading to at least 2.3 and reopen if the issue is still there. There have been a LOT of fixes to platforms' SQL generation since 2.2.x.
Also if you still encounter the issue, please add your mapping information, otherwise it will be hard to rack the issue down.

@doctrinebot

Comment created by @deeky666:

Oh sorry read your ORM version constraint wrong. Reopening. Please can you give the exact DBAL version you are using and mapping information? Thanks.

@doctrinebot

Comment created by charlie_wasp:

Vote for this issue.

postgres: 9.3,
doctrine/orm: "2.2,>=2.2.3",
doctrine/doctrine-bundle: "
1.3",
doctrine/migrations": "1.0.x-dev",
doctrine/doctrine-migrations-bundle": "2.1.x-dev"

@doctrinebot doctrinebot added the Bug label Dec 7, 2015
@deeky666 deeky666 was assigned by doctrinebot Dec 7, 2015
@deeky666
Doctrine member

Cannot reproduce, not enough information given. Closing for now. If this still is an issue, please report how to reproduce and I'll reopen.

@deeky666 deeky666 closed this Jan 10, 2016
@seyfer

Have same issue now with Postgre

DROP SEQUENCE

generates every time. I don't know why.

@deeky666
Doctrine member

@seyfer we need to be able to reproduce this otherwise we can't do anything about it. Please try to track down the issue to DBAL code as we are not the maintainers of migrations here. Maybe providing the mapping information that cause the issue could help for now if you are not able to track the issue down to DBAL.

@scaytrase

We have the same issue. We use filter to generate migrations for only one scheme and diff generates drop\create sequence expressions. Applying this migration results in duplicate sequence error

@MisterGrouik

Same problem.

@MisterGrouik
MisterGrouik commented Jun 24, 2016 edited

Hoooo my bad.

Actually I made it worked !
The problem came from the fact that I defined a "schema_filter" to exclude some tables I created manually.
This filter was ~^(?!users_)~

I had some tables created manually, and some created by Doctrine beginning by "users_".
Strangely, with the filter defined as ~^(?!users_)~, the diff command added some "CREATE SEQUENCE ***" concerning the "users_" table generated by Doctrine.

So I had to redefined the filter like that
~^(?!users_banque|users_coord|users_cv|users_equipement|users_identite|users_langue|users_luxe|users_statut|users_vehicule)~
to defined exactely the tables that I manually created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment