Django Migrations: Pitfalls and Solutions

Oct 18 12:00 PM PDT :calendar: to 12:25 pm
Audience level: Intermediate

About This Talk

Django’s migration system is one of its greatest strengths as a framework. It can automatically generate migrations based on your changes to your models and can detect which migrations need to be applied to a database. But, as the size of your development team and user base scale, there are pitfalls that you need to be aware of. Not all migrations can be safely reversed, and trying to rewind bad migrations on a production database can cause a data disaster. Not all migrations can be safely deployed without downtime, and trying to deploy them can give your users and your engineers a wall of errors.

This talk will cover the following:

  1. How to manage migrations across multiple code branches
  2. Reversible migrations: how to write migrations so that they can be safely undone
  3. Backwards compatible migrations: which migrations can be run as part of a deploy without causing downtime or errors
  4. Handling failed migrations as part of a deployment

This talk assumes familiarity with the management commands makemigrations and migrate. It’s likely to be most helpful for people working on a Django project where there are many branches being worked on simultaneously or for those working on applications with moderate to high uptime requirements.


    Photo of Benjamin

    Benjamin "Zags" Zagorsky

    Zags is the CTO of Zagaran, Inc., a contract software company. He has led dozens of full-stack software development projects between both the private and public sectors. Zags graduated from Harvard in 2012 with bachelor’s and master’s degrees in Computer Science. He previously worked at Google, mentors for TechStars, and is a published game theorist.