2016-03

2016-03-17 Cleaning up Django migrations

Background

Djangos database migrations system greatly simplifies the task of keeping multiple databases in sync (the schema, not the data) as the schema evolves over time. Formerly known as South, Djangos migrations system is also a good example of how Django embraces and includes 3rd party packages when it makes sense.

Over the last year I (and colleagues) have been developing a Django-based provisioning system for an ISP. The system has grown rather large with a lot of models (160ish plus abstract models at the moment) and plenty of foreignkey constraints connecting them. Migrations have helped us keep everything in sync between local instances on three developers laptops, staging, and production. There is simply no way we could have have done this, in the time we’ve done it, without the migrations system.

The following was all done on Django 1.8.5 but the approach should work fine on other recent Django versions.