Digging Into Django's Migrations

Andrew Godwin

Audience level:

Intermediate

Description

A deep dive into the innards of Django's new migrations system - learn how it's separated into different components, the steps it uses to work out what you've changed, the secrets of abstracting schema changes across multiple backends, and what was tried that didn't work out so well - and more!

Abstract

The new migrations system in Django is ostensibly based on South, but in reality is a bigger overhaul of the core concept of per-app migrations.

Fortunately, due to its origin and relative isolation, it's also one of the easiest parts of the Django to understand as a complete unit, and this talk aims to give you that understanding. We'll go through the ten or so different components and how they interact - including the graph representation we use, the dependency resolvers, the autodetector, the optimiser and more - and then look at the typical route the management commands take through the stack.

Then, learn about some of the problems and design issues both South and the new migrations had to deal with during their development, and how that affected their design - and where there's still problems that need to be solved.