What is your favorite solution for managing database migrations in django?

Question:

I quite like Rails’ database migration management system. It is not 100% perfect, but it does the trick. Django does not ship with such a database migration system (yet?) but there are a number of open source projects to do just that, such as django-evolution and south for example.

So I am wondering, what database migration management solution for django do you prefer? (one option per answer please)

Asked By: MiniQuark

||

Answers:

I like django-evolution:

pros:

  • clean design
  • no SQL needed
  • flexible
  • trivial to install
  • easy to use

cons:

  • migrations are not fixed in the codebase
  • a risk exists of accidently running a migration twice
Answered By: MiniQuark

Migratory looks nice and simple.

Answered By: mcella

We use Django at work, and we’ve been using dmigrations. While it has its quirks, it’s been useful so far. Some features:

  • It uses a table in the database to keep track of which migrations have been applied.
  • Because it knows which ones have been applied, you can migrate up and back down.
  • It integrates with manage.py as a command.
  • The individual migration scripts are Python, but if your migration logic is pure SQL, dmigrations makes it easy to just can the SQL and have it executed.

One problem is that it only currently supports MySQL. However, one of our guys make a local hack to it to support PostgreSQL, which we use. As I recall, the hack wasn’t all that extensive, so it shouldn’t be terribly difficult to hack it up to support other RDBMSs.

Answered By: Brian Clapper

I’ve been using South, but Migratory looks promising as well.

Answered By: akaihola

Besides South, dmigrations, django-evolution, and Migratory I thought I would add simplemigrations as another tool I’ve seen for automating Django migrations.

I’ve used three of these in the past but do migrations by hand now. I’m thinking about trying South again due to the latest features added.

Answered By: Van Gale

Just to note that since 2009, pretty much every project mentioned here other than South is dead. South is the de facto standard, for better or worse.

Answered By: Marcin

I’ve been using simple-db-migrate

Pros:

  • it allows me to rollback the migrations (IDK if other do this too).
  • integrates with manage.py
  • everyone that knows SQL can create a migration
  • it doesn’t run a migration twice: the application writes the migration information(timestamp, query, etc.) on a table

Cons:

  • if you add a migration with a lower timestamp than the latest migration installed, this migration doesn’t run
  • Only MySQL is supported
Answered By: mondaini

If you are using SQLAlchemy as your ORM then the de facto standard is Alembic.

Another alternative that haven’t been mentioned is yoyo-migrations.

Answered By: cwadding