Zero-Downtime Migration with Change Data Capture
DBShifts Engineering
The team building the migration platform
The classic migration plan — stop writes, copy everything, point the app at the new database — has a problem named in its first two words. For a database serving production traffic, "stop writes" can mean hours of downtime. Change Data Capture is how you migrate without the stop.
The snapshot + stream handoff
The trick is in the ordering:
- Mark — before copying anything, record the source's current replication position (binlog coordinates on MySQL, WAL LSN on PostgreSQL, a resume token on MongoDB).
- Snapshot — run the bulk migration normally. Writes keep happening; you don't care, because they're being logged past your marker.
- Replay — stream every change since the marker and apply it to the target. Inserts, updates, deletes — including changes to rows the snapshot already copied.
- Stay synced — keep consuming until the gap is seconds, then cut over at a moment you choose.
The overlap between snapshot and stream is intentional. Some events get applied twice — an insert for a row the snapshot already carried. Upsert-by-primary-key makes the replay idempotent, so the overlap is safe rather than a correctness bug.
Engine-specific capture
Every engine logs changes differently, so DBShifts speaks each dialect natively: MySQL/MariaDB row-based binlog, PostgreSQL logical replication slots, SQL Server's built-in CDC tables, MongoDB change streams.
The unglamorous parts that make it production-grade
- Ordering vs constraints — replayed events can arrive child-before-parent. The applier bypasses FK enforcement for the replication session (the same way native replicas do), instead of failing or permanently relaxing constraints.
- Backpressure — if the target falls behind or the error rate spikes, the consumer slows down instead of ballooning memory.
- Resumability — the stream position is checkpointed, so a restart resumes where it left off rather than re-snapshotting.
- Observability — lag, applied events, and apply errors are exported as metrics; you watch the gap shrink before deciding to cut over.
Migrate with the platform behind these posts
All 49 engine pairs live-tested. Validation, rollback, and CDC built in.
Start Free Migration