[DDC-1172] Schema tool does not drop sequences on table drop for PostgreSql platform Created: 26/May/11  Updated: 01/Mar/13  Resolved: 17/Jun/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: 2.0.5
Fix Version/s: 2.1
Security Level: All

Type: Bug Priority: Major
Reporter: Aigars Gedroics Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None

PostgreSql 8.4

Attachments: File DoctrineDropSequencePatch.diff    


When recreating database using


the second line fails with error that the sequence "tbl_id_seq" already exists. It's because the sequence is created without an owner column and schema tool doesn't include "drop sequence" statements in the drop SQL.

I've created a patch which fixes the problem for my environment. Revision numbers in patch is from the local SVN. Doctrine base is 2.0.5.

Comment by Benjamin Eberlei [ 05/Jun/11 ]

That will always drop all sequences also when you only pass some classes in there. We need to find a better solution for this problem.

Comment by Benjamin Eberlei [ 17/Jun/11 ]


Comment by Pierre-Yves LEBECQ [ 01/Mar/13 ]

I don't know if this is the right place to add a comment because this bug is quite old, and if anyone will see it but the code that fixed the reported bug seems to create a bug on my setup. The SchemaTool tries to drop two times the sequences, which produces an error.

The following SQL is generated :

ALTER TABLE utilisateurs DROP CONSTRAINT fk_497b315e7634f637;
ALTER TABLE utilisateurs DROP CONSTRAINT fk_497b315e19863134;
DROP SEQUENCE civilites_civ_id_seq;
DROP SEQUENCE utilisateursClientType_ucty_id_seq;
DROP SEQUENCE utilisateurs_user_id_seq;
DROP SEQUENCE civilites_civ_id_seq;
DROP SEQUENCE utilisateursclienttype_ucty_id_seq;
DROP SEQUENCE utilisateurs_user_id_seq;
DROP TABLE civilites;
DROP TABLE utilisateursClientType;
DROP TABLE utilisateurs

I'm using postgres 9.1.8, Doctrine 2.3.2

Generated at Sat Aug 29 05:41:36 EDT 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.