Migration waves and cutover
Build waves around evidence
A wave is a group of workloads moved within a coordinated interval. Start with a low-criticality pilot, then improve the runbook before moving sensitive workloads. A wave must have named owners, prerequisite services, test environments, a change window, communication plan and explicit entry and exit criteria. Plan compatible interfaces during coexistence; keeping a database on-premises while moving an app can add latency and dependencies.
Northwind's wave 0 prepares identity, network, logging, backups and recovery drills. Wave 1 moves Catalog with its validated database. Wave 2 moves Orders and its database after payment integration tests and rehearsal. Finance is retained pending license review. No old system is removed during this exercise.
Full load versus CDC
A full load copies existing records. In an offline migration, writes are stopped for the copy and validation. In an online migration, a consistent snapshot is followed by change data capture (CDC), which captures inserts, updates and deletes from supported source change logs. A checkpoint records progress; it is not proof of correct data. Log retention must exceed replication outages and snapshot duration, or resnapshotting may be necessary. Apply transaction order, schema changes and deletes according to engine guarantees. Some objects, jobs and permissions need separate migration.
For a planned window of 15 minutes, allow 3 minutes to quiesce writes, 4 to drain and validate, 2 to redirect, 2 for smoke tests, leaving 4 minutes contingency. The rollback deadline must also reserve time to restore service; don't wait until the entire window is exhausted. For example, reserve 5 minutes for rollback and abort by minute 10 unless approved acceptance has already occurred. RPO is allowable loss, RTO allowable restoration time after disruption; the maintenance budget is a separate constraint. Low replication lag alone does not prove zero loss.
Cutover gates and rollback boundaries
Before cutover, rehearse a restore, confirm monitoring, dependencies, target capacity and backups, and assign an approval owner. Announce maintenance and freeze source writes (including background jobs and external writers); record the final source checkpoint. Drain replication and confirm the target has applied that checkpoint. Compare counts, keyed content, constraints and business totals at a consistent point, and verify roles, schema, sequences, jobs and application behavior. Test smoke requests using synthetic data. Switch traffic only after explicit approval and keep the old source fenced from writes to prevent split-brain.
If validation fails before the target accepts writes, keep or restore source routing and source writer access after confirming target is fenced. Once target writes are accepted, a DNS flip alone can lose those writes. Use a rehearsed reverse replication or reconciliation plan, with conflict rules, before failback; if not possible, escalate and roll forward or recover under the approved plan. DNS caches, pooled connections and old credentials can delay switching; check real client paths. Monitor errors, latency, throughput and business invariants during hypercare. Keep the old source protected and recoverable until owner approval, retention checks and dependencies permit decommissioning.
Run a local database migration rehearsal
The following Python 3 standard-library example uses two in-memory SQLite databases. No files, cloud accounts, networks or credentials are required. Amounts are integer cents. The initial copy is followed by a simulated update. The decision function checks exact sorted rows, not just row counts. The flags represent independently verified evidence, not automated proof. The 15-minute budget in the toy gate is the decision deadline; in a real plan pass the earlier deadline that reserves rollback time (e.g. 10 minutes above). The model does not implement CDC, concurrent writes, distributed transactions or a live cutover.
import sqlite3
def make_db(rows): db = sqlite3.connect(":memory:") db.execute("CREATE TABLE orders (id INTEGER PRIMARY KEY, cents INTEGER NOT NULL CHECK(cents >= 0))") with db: db.executemany("INSERT INTO orders VALUES (?, ?)", rows) return db
def same_orders(source, target): query = "SELECT id, cents FROM orders ORDER BY id" return source.execute(query).fetchall() == target.execute(query).fetchall()
def decision(source, target, *, frozen, caught_up, smoke_ok, rollback_ready, elapsed, budget, target_writes=False): if elapsed < 0 or budget <= 0: raise ValueError("Invalid maintenance window") if target_writes: return "reconcile-before-failback" if elapsed >= budget: return "abort-before-cutover" if not all((frozen, caught_up, smoke_ok, rollback_ready)): return "hold" return "ready-for-approval" if same_orders(source, target) else "hold"
source = make_db([(1, 1500), (2, 900)])target = make_db(source.execute("SELECT id, cents FROM orders"))with source: source.execute("UPDATE orders SET cents = 1100 WHERE id = 2")flags = dict(frozen=True, caught_up=True, smoke_ok=True, rollback_ready=True, elapsed=7, budget=15)print(decision(source, target, **flags))# Simulated final change application after source writes stop.with target: target.execute("UPDATE orders SET cents = 1100 WHERE id = 2")print(decision(source, target, **flags))print(decision(source, target, **dict(flags, target_writes=True)))source.close()target.close()Expected output:
holdready-for-approvalreconcile-before-failbackThe first result holds because equal row counts do not guarantee equal values. After applying the final update, the data match. The third result models a later rollback request after the target accepted new writes; reconciliation is necessary before any return to the source. It is not a recommendation to stop normal operation after successful cutover. Modify the sample to delete a row from the target and observe hold. Try elapsed=15 to see the abort outcome. In production, validate complete business invariants, not only a small table; keep the approval and actual traffic switch outside the checker.
Acceptance and decommissioning evidence
| Gate | Evidence | Owner |
|---|---|---|
| Preflight | Dependency and license sign-off, restore rehearsal | Migration lead |
| Data | Source checkpoint applied; no unmatched records; object and business checks | Database owner |
| Service | Synthetic checkout passes; latency and errors within agreed bounds | Application owner |
| Recovery | Tested rollback/failback and fenced writers | Incident commander |
| Hypercare | Agreed observation window, reconciliation and customer acceptance | Service owner |
A useful acceptance threshold for the fictional Orders service is zero unmatched order IDs and totals, all smoke checks passing, and measured restoration within the agreed recovery limit. Choose performance thresholds against a baseline rather than inventing a provider guarantee. Record actual times and observations. A decommission plan must address data retention, backups, audit trails, contract termination, DNS, credentials and billing. Obtain explicit owner authorization after the rollback horizon. This chapter only creates a plan; no actual resource is removed.
Practice and recap
Create a three-wave plan, including a pilot and the critical order system. For a 20-minute window with a 6-minute rollback reserve, set the latest safe decision at minute 14. Run the local code with a mismatched amount, a missing record, and a false smoke-test flag. Explain why each blocks cutover. Describe what additional evidence is needed if the target has already accepted orders. Deliver a written acceptance checklist and an escalation decision; do not perform a real migration.
Remember: migration success means the business service and data are correct, recoverable and owned, not merely that replication finished.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Migration waves and cutover — knowledge check
Choose the best answer for each offline scenario.
Counts match but order amounts differ. What is the decision?
What does CDC capture in a supported database migration?
A 20-minute window reserves 6 minutes for rollback. What is the latest decision time?
The target has accepted new orders. What must precede failback?
When is the old source ready for decommissioning?