[DDC-993] Cookbook: Overriding the ID Generator during a database migration Created: 19/Jan/11 Updated: 28/Oct/12
|Project:||Doctrine 2 - ORM|
|Reporter:||Timo A. Hummel||Assignee:||Benjamin Eberlei|
If you need to override the ID Generator, e.g. during a migration, you can do that in your migration script as follows:
Make sure that both calls equal to the same generator type. You can now modify the @Id fields in your entities. Additionally, make sure that you set the IdGenerator after you created the database using e.g. SchemaTool->create().
|Comment by Endre Kósa [ 27/Oct/12 ]|
Hi, this doesn't seem to work for me. I have written a small database export / import utility. As long as I use the automatic ID generation, everything works flawlessly, but I'm trying to preserve the existing IDs. I do exactly what you've suggested in your post. It works for @OneToOne relations, but I get the following error messages when persisting entities that are parts of @ManyToOne relations:
|Comment by Endre Kósa [ 28/Oct/12 ]|
Never mind. I've upgraded to Doctrine 2.3.0 and it works as expected.