Your database migrations are bad and you should feel bad
summary
Argues that instead of accumulating numbered migration files, use a Postgres-aware diff tool: a command-line plus Python library called migrate that compares a development pg_dump schema and a live dump, emits the exact SQL statements to move from live to goal, and supports temporary databases for fast local cycles. Workflow includes a checked-in pending.sql, running tests both pre- and post-migration, and heuristics for function dependencies; requires access to production schema dumps.
AI-written summary · about
chapters (24)
- 0:00Introduction
- 1:40Structure
- 5:52Questions to answer
- 6:28The usual answer
- 6:47Framework lockin
- 7:28Database management
- 7:54Primitive table store
- 8:42Status quo
- 8:54Three schema versions
- 9:34Migration files and version numbers
- 10:19Database Diff
- 12:11Goal Schema
- 12:41Goal Schema Example
- 14:11Review the File
- 17:03Testing
- 17:54Test Fixtures
- 18:52Trustful migrations
- 19:10Independence from our framework
- 20:05Questions
- 23:05Changes
- 23:55Deployment workflow
- 25:34Temporary database
- 26:51pgdump
- 28:04SQL queries
related talks
52mManaging PostgreSQL changes for the Agile DBA
56mSane schema migrations with Alembic and Postgres
33mPeaceful Django Migrations with Efe Öge
48mMigrating to PostgreSQL: Strategies, Sovereignty, and Success
57mDjangoCon 2008 Panel: Schema Evolution
36mTales from the Postgres Front, and What We Can Learn
31mSpace Django: Migrating and Redesigning a Database while Hunting for Satellites.
31mHelp! My Database Is The Bottleneck
