[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
Environment:

PostgreSql 8.4


Attachments: File DoctrineDropSequencePatch.diff    

 Description   

When recreating database using

$schemaTool->dropSchema($metaDatas);
$schemaTool->createSchema($metaDatas);

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.



 Comments   
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 ]

Fixed.

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 Sun Apr 20 14:19:44 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.