Zero-Downtime Database Migrations
Expand/contract migrations, backfills, and feature flags that keep services online during schema change.
Nestlancer Editorial

Schema changes are production incidents waiting to happen unless you use expand/contract phases and feature flags that decouple deploy from DDL.
Expand/contract rhythm
- Expand: add nullable column or new table
- Migrate: dual-write or backfill job with idempotent batches
- Switch: application reads new column behind flag
- Contract: drop old column after traffic fully cut over
Never rename in place—add new, migrate, delete old.
Backfill safely
-- Batch updates avoid long locks
UPDATE users SET display_name = full_name
WHERE id IN (SELECT id FROM users WHERE display_name IS NULL LIMIT 5000);
Run during low traffic; monitor replication lag on replicas.
Feature flag coordination
- Flag off: old schema path only
- Flag on for internal staff: validate new path
- Gradual percentage rollout with error rate dashboard
- Flag removal only after contract column dropped
Prisma migration hygiene
Squash only in dev. Production migrations stay incremental and reversible for one release.
Zero-downtime migrations are a collaboration between app and DBA—ship code that tolerates both schemas during the transition window.
Comments
Loading comments…
Related posts

Case Studies
Cutting Deploy Time from 45 Minutes to Five
CI caching, smaller artifacts, and service-level pipelines after monolith split.

Case Studies
Scaling a Freelance Marketplace Architecture
Matching algorithms, escrow flows, and dispute resolution at growing GMV.

Case Studies
GDPR Compliance Platform Rebuild
Data maps, deletion workflows, and consent logging across microservices.

Case Studies
Migrating from WebSockets to SSE
Simpler infra, CDN friendliness, and trade-offs for one-way realtime feeds.