Context in practice For engineers
Database migration plan: carry production constraints into each stage
A database migration plan must protect the transitions as well as the destination. Carry each applicable production constraint into the stage it changes, then name the evidence needed before advancing or removing compatibility support.
Plan the transitions, not only the final design.
A field rename can look complete in the new producer and new consumer while breaking a reader that has not moved yet. Restoring the producer binary may not repair messages it already emitted. The useful planning question is which combinations of code and stored data can exist at each stage.
Start from a constraint with an inspected source and current scope. Record why it exists, who owns the affected consumer, and what observation would allow the constraint to be retired. This article proposes a transition map for that work; it is not a complete migration procedure or a claim of guaranteed rollback.
Name the fictional contract and the missing evidence.
This entire example is fictional, including the decision labels, components and statuses. A service emits events containing display_name. The proposed replacement is label, with the same accepted meaning. Compatibility decision C7 requires a nightly consumer to keep working until its owner verifies its migration. Events can be delayed or replayed from retained queues and a dead-letter store.
The team has a proposed new producer and one new reader. Their isolated tests pass in this fictional account, but the nightly consumer has not been inspected. The consumer inventory and replay horizon are also incomplete. Those gaps block a production transition; they are not details to fill in with assumptions.
The candidate plan below prepares readers to accept either old-form or new-form messages before changing what producers emit. It assumes the field meaning stays the same. It does not assume a message containing both fields is accepted, or invent precedence if their values differ. If the team chooses that alternative, it needs an explicit contract and parser checks: an added field can still be rejected by a strict reader.
| Known constraint or gap | Stage it changes | Evidence to seek |
|---|---|---|
| C7 protects the nightly consumer. | Before activating the new producer. | Owner-supplied compatibility results show the inspected reader version accepts and interprets the new form in the checked scope. |
| Old events may arrive after a code update. | Reader preparation and later cleanup. | Permitted old-message fixtures and the full retained/replay source inventory. |
| Old and new versions can coexist. | Forward rollout and rollback. | Checks exercise the allowed version combinations and message forms. |
| Inventory and replay horizon are incomplete. | Activation and retirement decisions. | Resolve the missing owners/sources; keep the affected stage on hold. |
Give each stage a condition for proceeding.
AWS’s rollback-safety explanation separates preparing readers from activating a new written format. It also calls for checking every affected participant and testing forward and backward transitions. That supports looking beyond a successful final-version test. The event contract, stages and checks below remain this article’s proposed fictional application.
The owner of the migration record coordinates the stages; each consumer owner supplies evidence for that consumer. A deployment status or an empty error chart cannot stand in for an uninspected reader. If the inventory is incomplete, do not declare that every reader has been prepared.
| Stage | Candidate action | Proceed or hold condition |
|---|---|---|
| Inspect the boundary | Find producers, readers, replay stores and the current contract. | Proceed with permitted inspection. Hold activation while a relevant owner or path is unknown. |
| Prepare readers | Readers accept old-form and new-form messages; producers still emit the old form. | Run scoped compatibility checks and verify every affected deployed reader, including the nightly path. No result is supplied by this plan. |
| Activate producers | Change producers to emit the new form while prepared readers remain. | Hold in this example: the nightly consumer and inventory are unverified. Record permitted rollback targets before any new-form message is emitted. |
| Retire old-form support | Consider removing old-form reading after the transition. | Hold until eligible retained/replayed messages and supported producer rollback versions no longer require it, with owner-backed evidence. |
Check the combinations that the transition permits.
A useful check names the producer form, reader version and expected interpretation. Include old messages reaching a prepared reader, new messages reaching every prepared consumer, and both forms while producer versions coexist. Exercise the actual delayed or replayed path with permitted fixtures rather than testing only a direct call.
Also identify a forbidden combination: the initial old-only reader receiving a new-form message. The plan must prevent that combination or provide a separately accepted compatibility mechanism. It must not call the combination safe merely because the new pair passed.
Keep semantic assertions as well as parsing assertions. A reader accepting a field without using its value correctly does not preserve the contract. Record actual inputs, versions, results and unchecked paths after execution. The checks in this article are proposals, not test results.
State which rollback targets remain compatible.
Before activation, restoring the original readers may be possible because producers still write the old form, subject to the actual checks. After new-form messages have been emitted, reverting every component to its initial version can expose an old-only reader to data it cannot read. A binary rollback does not rewrite queued or stored events.
The candidate plan therefore retains prepared readers when rolling a producer back to the old form. Whether that rollback works still needs its scoped test and operational evidence. Removing old-form reading later changes the boundary again: an old-form producer may cease to be an acceptable rollback target.
Cleanup needs evidence about eligible replay sources, not simply elapsed time or current traffic. If old messages remain replayable, retain support or establish and verify an accepted conversion/replay procedure. If the replay horizon is unknown, leave retirement blocked. Do not invent a destructive cleanup step to make the plan look finished.
Carry the constraint into the implementation brief.
Keep one concise record with source links and owners. Update it when a stage is observed, a consumer changes or a new retained-data path is discovered. This filled card describes the fictional plan at its current cutoff; it grants no deployment authority.
Ordinary contract files, version history and consumer owners may supply everything needed. Retrieval can locate an older reason, but it cannot establish a consumer’s current deployment or accept deletion. For your next migration, attach one production constraint to the exact transition stage and check it changes.
Goal: change event display_name to label without changing its accepted meaning.
Source/constraint: fictional C7 preserves the nightly consumer until its owner verifies migration.
Owners: migration maintainer coordinates; each producer, consumer and replay-store owner supplies scoped evidence.
Current evidence: one new pair reportedly passes isolated checks; nightly reader and inventory unverified.
Proceed now: permitted contract/path inspection and a draft compatibility matrix.
Candidate sequence: prepare readers for both forms; verify participants; activate new-form producers.
Hold now: activation, old-form retirement and any claim of production readiness.
Rollback boundary: emitted new-form messages prevent assuming initial old-only readers can return.
Retirement condition: supported producers and eligible retained/replay messages no longer need old-form reading, with evidence.
Unknowns: complete consumer inventory, replay horizon and actual transition/rollback results.
Refresh trigger: observed rollout, changed owner/contract, new replay source or executed check.Frequently asked questions
What should a database migration plan include?
The stages of the transition, not only the final design. For each applicable production constraint, record its source, why it exists, who owns the affected consumer, and which stage it changes. Give each stage a condition for proceeding or holding, name the evidence needed, state which rollback targets remain compatible, and define when old-format support can be retired.
How do you rename a field without breaking consumers?
Prepare readers to accept both the old and new forms while producers still emit the old form. Verify every affected reader, including delayed or replayed paths, before switching producers to the new form. Retire old-form reading only when supported rollback versions and retained or replayable messages no longer need it, with owner-backed evidence.
Why can't I just roll back the code after a migration?
Rolling back a binary does not rewrite messages or data it already emitted. After new-form data exists, reverting every component to its initial version can expose an old-only reader to data it cannot read. State which rollback targets remain compatible before activation, and keep prepared readers in place when rolling a producer back.
When is it safe to remove backward compatibility in a migration?
When evidence shows that eligible retained or replayable data and supported rollback versions no longer require it. Elapsed time or current traffic alone is not enough. If old data can still be replayed, keep support or establish and verify an accepted conversion procedure. If the replay horizon is unknown, leave retirement blocked.
Sources and further reading
Prepared with AI assistance and reviewed for source fidelity and practical usefulness. Examples marked fictional are illustrations, not customer results.