procedure Operations & procedures
Expand-contract migrations across application versions
A read switch and a schema removal answer different questions: are the new values current, and could an active consumer or a rollback still need the old interface?
What it means
Old and new application versions need overlapping database interfaces when they run at the same time but expect different structures. If the old version reads one column and the new version expects its replacement, adding the replacement lets the new version find it. Keeping the original lets the old version keep working. This is the expand part of an expand-contract migration. Contract means removing the old interface after nothing needs it, including any version you might still need to roll back to.
Try it
Simulation. Start with the expanded schema, two old app instances, three new ones, and readiness as the proposed next step. Both versions have the interface they need. But only 80 of 100 records have verified current values in the new structure. The result is backfill: 20 records remain. The inventory and rollback settings are not used for this result.
Expand-contract migrations across application versions
Explain why old and new app versions need overlapping database schema during deployments
Data migration incomplete; do not switch reads or contract.
Coexisting application versions
- Schemaexpanded
- Old consumers compatibleYes
- New consumers compatibleYes
Requested action
- Actionreadiness
- Consumer verificationNot evaluated / established
- Old rollback requiredNot evaluated / established
- Outcomebackfill
Readiness, switch and contraction are separate modeled actions. This model never executes a deployment, schema change or rollback.
Evaluated inputs
- Required scenario evidence
- provided
- Schema / consumer phase
- expanded
- Backfilled and verified records
- 80 count
- Proposed next step
- readiness
Not evaluated: Old app instances · New app instances · All old consumers inventoried · Old-version rollback still required
Exactly 100 stipulated records; copied means checked current values including intervening writes. New app requires new interface, old app old interface, expanded provides both. No actual dual-write, SQL, locks, data integrity proof, deployment or irreversible action. Readiness is scope-bound.
About this model
The controls set only a local, bounded scenario. The computed branch is not a verdict about a live system. Inputs listed as not evaluated did not participate in this branch after validation.
Reset restores the original inputs. It does not change the open or closed state of help or FAQ answers.
- Set the proposed next step to
switch. With 80 records verified, the switch is still held atbackfill. Now change just the verified count to 100. The result becomesreadyfor the modeled read switch. The old interface is still present. - Leave the count at 100 and change just the proposed step to
contract. The result becomesblocked. The two old instances can coexist with the new ones precisely because the interface you propose to remove is still there. - Set old app instances to 0. With the inventory marked complete, the remaining blocker is now rollback: the old version would need its interface again. Change the rollback requirement from
yestonoto seereadyfor contraction under those assumptions.
Reset returns to the original 80-record readiness example. These choices compare proposed steps; none switches traffic, changes a database, or establishes that a real migration has finished.
What each phase makes possible
The table answers one question: if this application version is running, does the schema provide the interface it expects? It says nothing yet about the values in that interface.
| Schema phase | Old app needs original column | New app needs replacement column |
|---|---|---|
| Old-only | Present | Missing |
| Expanded | Present | Present |
| New-only | Missing | Present |
Consider the initial example again, but change the schema from expanded to old-only. The same three new instances now need a missing column. The result is incompatible, not backfill: copying more records would not fix a missing interface. Changing to new-only instead leaves the two old instances without their column. Starting the first new instance is therefore not a reason to remove the old column.
The intended sequence is expand → backfill → switch reads → contract. Expansion answers whether both versions can find their columns. Backfill supplies the values for existing records. A record counts as verified here only if the replacement holds its current value, including writes that happened while data was being copied. A count of rows visited by a copy job is not the same evidence. If completion is unknown, select missing for required scenario evidence rather than guessing a count. The simulation then gives no readiness result.
Switching reads changes which values are used; contracting changes which interfaces are available at all. That is why a completed backfill can support the former without justifying the latter. Even a ready result for a proposed switch does not record that the switch took place.
A fully copied dataset is not a license to remove the old interface. Set copied to 100 and request contract with two old consumers still present. The compatibility matrix may be fine in the expanded phase, yet contraction is blocked. If the schema is already new-only and old consumers are present, incompatibility takes precedence. The readiness check does not record an executed switch.
In practice
Start with a read-only inventory. Record the current schema, which versions and other consumers use each interface, and which version the rollback plan would restore. Keep that before-state with the evidence for the migration. For a proposed switch, look for verification of current values. For a proposed contraction, also look for evidence that consumers actually moved off the old interface. An inventory lists what to check; the list alone does not show that every reader or writer has switched.
Stop before changing the database if the supported database version, consumer inventory, migration completion, or rollback requirement is unknown. A real change needs an authorized operator and a plan specific to that database: identify the exact change and required permissions, preserve the before-state, and establish how to verify the affected versions and data after the change and after any rollback. Compatibility alone does not establish availability. In PostgreSQL 18, for example, lock and validation requirements vary by ALTER TABLE subcommand; the simulation does not evaluate either.
The useful decision is not “Is the new version running?” It is “What would still need the old interface if it disappeared?” If the answer is an active consumer, the rollback version, or “we don't know,” keep the overlap.
Frequently asked questions
Editorial questions based on the listed sources and explicitly labeled local examples.
Does expand alone migrate data?
No; backfill can be a separate stage.
Can rollback require old columns?
Yes in this example: rollback to the old app requires its old interface, so removing that interface before the rollback window closes violates the modeled compatibility gate.
Does compatible schema guarantee migration is nonblocking?
No. A schema can be compatible with both application versions and still require locks, table validation or substantial work during a database change. PostgreSQL ALTER TABLE subcommands have different locking and validation behavior. Plan these risks separately from compatibility.
What must be checked before contract?
Check active old consumers, the verified backfill and any requirement to roll back to the old interface. In the expanded fixture even a 100% copy leaves contraction blocked if an old consumer remains. It does not authorize actual DDL.
Sources & model boundaries
Primary references used for this explanation. The interactive example is an educational model, not a live check.
- Parallel Change (pattern description)
Expand, migrate, contract. Maintain both interfaces while consumers migrate; remove old interface afterward. Database-specific backfill and locks are separate.
Checked .
- PostgreSQL ALTER TABLE
ALTER TABLE: lock modes and validation. ALTER TABLE lock modes vary by subcommand; default exclusive mode is subject to documented exceptions.
Checked .