Django migrations, friend or foe? Optimize them for testing
summary
Covers concrete Django commands (makemigrations, migrate, showmigrations, sqlmigrate) and measures effect on CI test time: a 20-app demo spends ~30s creating the test DB but only 1s running tests. Compares tactics: set MIGRATE=False (avoids migrations but adds ~5s model analysis), keepdb (saves ~20s locally but causes growing PKs and CI caching complexity), cdb (seed database) restores a dumped SQL file on CI and gives the best speed, while squashmigrations helps reviewability but only saves ~1s. Presents a custom CI seed DB implementation that took weeks to build and worked in production.
AI-written summary Β· about
chapters (12)
- 0:00Introduction
- 1:08What are Django migrations
- 3:35Migration commands explained
- 6:07Modifying fields and models
- 8:00Custom migration code
- 10:12Fixtures and data loading
- 12:01Testing performance issues
- 13:53Optimizing test migrations
- 15:57External test databases
- 17:31Squashing migrations
- 21:48Cost of optimization
- 22:53Q&A
related talks
25mDjango migrations, friend or foe? Optimize your Django migrations for faster testing
21mMigrating to Success: Unleashing the Power of Django Migrations
21mDjango's Migrations: A Retrospective
43mHow to avoid database migration hell
29mMigrating Data Quickly and Safely
57mDjangoCon 2008 Panel: Schema Evolution
25mDeploying Django migrations at Kraken scale with Tim Bell
30mContinuous Integration Testing for Your Database Migrations
