Roll out a database schema change without downtime
8 steps · about 3 h 12 min · Intermediate
- Treat schema evolution as continuous work (guide, Martin Fowler, 28 min)
Connect database changes to version control, automated deployment and compatibility between application versions.
- Map the expand-and-contract sequence (guide, Prisma Data Guide, 24 min)
Separate additive schema, data movement and later removal so deploy order stays reversible.
- Backfill in controlled batches (reference, PostgreSQL documentation, 24 min)
Update existing rows with an explicit predicate and repeatable ordering rather than one unbounded data rewrite.
- Observe migration activity and waits (reference, PostgreSQL documentation, 24 min)
Inspect active sessions and wait events during rehearsal and rollout instead of discovering blocked traffic from timeouts alone.
- Build indexes while writes continue (reference, PostgreSQL documentation, 20 min)
Use concurrent index construction when its longer multi-phase behavior is preferable to blocking table writes.
- Add constraints in controlled phases (reference, PostgreSQL documentation, 24 min)
Use NOT VALID and later validation where appropriate to separate enforcement planning from an immediate full-table check.
- Make the application rollout repeatable (guide, GitLab Docs, 24 min)
Coordinate compatible binaries, background data movement and later cleanup through an auditable migration process.
- Canary the read and write switch (guide, Google SRE Workbook, 24 min)
Observe correctness and load on a small slice before committing all traffic or contracting the old schema.