views:

32

answers:

2

When you run syncdb in Django, the primary keys of the content types will be recomputed. If I create new models, the next time I run syncdb, the primary keys of the content types will be different.

If I have an application running in production, how can I update the database with the new models and keep the integrity of content type pks?

+1  A: 

The problem is solved in Django 1.2 (which is supposed to come out in two weeks) with natural keys.

Ludwik Trammer
It's already fixed if you are running the django trunk as well.
wizard
+2  A: 

Running syncdb doesn't update existing ContentType values - these are stored in the database and aren't changed. So relations that depend on them won't be affected.

Newly defined models will however get new ContentType values when you run syncdb, and there's currently no way of defining in advance what those will be. As Ludwik points out, this issue is solved in 1.2.

Daniel Roseman