This question touches the subject of zero downtime schema migrations in Django (like this one perhaps).
A two-way compatible schema migration deployment is usually as follows (correct me if this list is missing a step):
- Scale up old code.
- Create new schema change with all fields nullable.
- Deploy schema change.
- Create new code change that uses new fields.
- Deploy new code.
- Scale down old code.
- Optionally deploy new changes that make these fields non-nullable.
However, I have not found any resources in the Django docs about testing steps 2, 3, and 4. Ideally, before makemigrations
generates a migration file, a series of tests should pass to indicate that the current codebase can run before and after this migration is run.
Question: is there already a built-in mechanism in Django, by which the two interleaved states ((old code, new schema)
, (new code, old schema)
) during a hypothetical zero downtime forwards and backwards migration, can be tested?