Wednesday, December 15, 2010

Doctrine 1.2 inheritance bug

While working on news and articles system for my project I have encountered an annoying problem with doctrine migrate task. It was giving me a bunch of errors related to indexes in the database tables and wasn't performing migrations correctly. In the beginning I thought it is me doing something wrong but after several approaches I've came to conclusion that this time I'm not a reason.



It took me a while and it involved dropping and rebuilding the database but I've found out what's wrong. The basic reason is that I'm using doctrine column aggregation table inheritance in my project. It works fine when you have one child table. But if you have more of them, whenever you run doctrine:build-sql or doctrine:generate-migrations-diff tasks, for some reason sql queries for one of the child tables are generated twice. This applies to all create and alter queries.

I was trying to find a solution but then I came across following bug reports:
http://www.doctrine-project.org/jira/browse/DC-536
http://www.doctrine-project.org/jira/browse/DC-123

As one can see, the issue was first encountered back in 2009 and it looks like no one is going to fix it as inheritance in Doctrine 1.x is "severely flawed" (read: screwed). What a shame that documentation doesn't mention about it... In bigger projects doing migrations manually is a real pain in the ass. So now I have to rebuild the schema and all my models to get rid of the doctrine inheritance and remember not to use it ever again.

No comments:

Post a Comment