Schema Migration with Django

Nathan Yergler, October 21st, 2008

Django is an amazing web framework; we built a lot of features in a very short period of time and Django [mostly] stayed out of our way. Last night as I was working on today’s feature upgrade for creativecommons.net I decided to tackle what lots of people see as its major weakness: schema migration. Rather, the lack of an integrated migration story.

I had seen some of the tools floating around and decided to watch the panel from Djangocon to get a better overview. For the record the represented tools are dmigrations, south and django-evolution. At some point while watching the video I think I was convinced each was the right solution; they all have features/use cases to recommend them.

Selecting the correct tool is an exercise in change management: it seems almost certain that Django will eventually adopt or create a “blessed” migration tool. And at that point, we need a way to move forward. Because of this I wound up choosing dmigrations. Sure, it doesn’t do some of the fancy stuff that south and django-evolution do (dependency tracking, model “fingerprinting”) but it does let us dump out the entire migration path as raw SQL and that’s something I can easily work with when it comes time to recreate our database on the “real’ platform.

2 Responses to “Schema Migration with Django”

macdet

it`s one way to do. at this time i prefer db_dump.py and alter by Hand for small mods.

# Author: limodou (limodou@gmail.com)
#
# This tool is used for dump and reload data from and into database
# You can see the help info through:
#
# python db_dump.py -h

Nathan Yergler

Sure, but having two different systems — one for “small” mods and one for larger ones — is a recipe for confusion. Using a migration tool lets us ensure that things are applied in the correct order.

Leave a Comment

Your first comments will be held for moderation, until your email address is approved.