1. LandOffer
  2. Blog
  3. All articles
  4. An Application Rollback Does Not Undo a Database Change: Plan Both Paths

Engineering Practice

An Application Rollback Does Not Undo a Database Change: Plan Both Paths

Plan application fallback and data recovery separately. An actual disposable SQLite fixture demonstrates read compatibility, partial backfill, stale writes and lossy recovery boundaries; a fictional decision record keeps production authorization and untested risks explicit.

9 min readLandOffer team

Rolling back application code does not automatically reverse schema changes, undo committed data writes or recover information a transformation discarded. Plan the code path and data path separately. Identify the read and write expectations of each application version against every database state. Preserve compatibility during transition and name who can stop, evaluate repair forward or authorize recovery. Treat contraction and data restoration as distinct decisions with their own evidence.

This LandOffer.ai guide combines primary documentation with an original disposable SQLite demonstration and a fictional recovery decision. The local test used synthetic rows in memory only. It did not deploy an application, run Prisma or PostgreSQL, connect to a business database, test concurrency or verify production recovery. Public sources were checked October 27, 2026; local observations are limited to the saved fixture and runtime.

A printmaker changes the removable press mechanism while previously printed sheets remain separately preserved.

Name the states that an application rollback leaves behind

A deployment can change code without changing the database it reconnects to. An old binary may find an added nullable column harmless, but fail when a column it reads has been removed. Even when its queries execute, an old writer can leave a new representation stale. A successful connection would not reveal that a returned value is stale or a fallback writer stops maintaining a new field. Check those behaviors before calling the version compatible.

Write the states your fallback would actually encounter: original schema, expanded schema, incomplete backfill, fully migrated data and contracted schema. Include background workers, integrations and other writers where they exist. A plan that considers only the newly deployed web process may miss another consumer of the old representation.

Danilo Sato's Parallel Change account, published May 13, 2014, separates expansion, migration of consumers and contraction. During the transition, old and new interfaces coexist. It also notes the complexity of maintaining both versions. The pattern provides a way to sequence change; it does not prove every transformation is reversible or remove the need to finish the transition deliberately.

Distinguish a rollback of an uncommitted transaction from a later application rollback. Transaction behavior depends on the database, operations and actual boundaries. A migration performed in committed batches may leave completed work after interruption. Do not infer either full reversal or partial persistence from the word “failed” without checking what actually committed.

Worked asset: a code and schema compatibility matrix

The original local fixture uses Python's SQLite library, reporting SQLite 3.54.1. A three-row cards table begins with an integer identifier and a label field. A new nullable normalized_label will contain the label with outer spaces removed and letters lowercased. This is an intentionally lossy teaching transformation, not a recommended product normalization policy.

The starting labels are North, north and South. The first two normalize to the same text, although their row identifiers remain distinct. No uniqueness constraint is added to the normalized field. The example cannot establish whether collapsing these display distinctions would be acceptable in a real product; that requires a product/data decision before migration.

Three small read functions stand in for application expectations. The old read requires a non-null label. The bridge read requires both columns to exist but still reads the legacy value. The new read requires every normalized_label to be non-null. A separate bridge writer updates both representations. These are simplified functions, not full applications or ORM clients.

Database state observed locally Old read Bridge read New read What this establishes
S0: only the legacy field exists Passes Fails: new column absent Fails: new column absent New paths cannot be assumed compatible before expansion
S1: new field added; two of three rows backfilled Passes Passes Fails the explicit incomplete-backfill assertion The old representation remains readable, while the strict new reader is not ready
S2: expanded schema with all three rows backfilled Passes Passes Passes These bounded read probes work; write consistency still needs its own check
S3: legacy field dropped after transition Fails: old column absent Fails: old column absent Passes Returning to the old read path cannot restore the removed field

At S1, the demonstration deliberately raises and catches an injected stop after committing the first two row updates. It is not a test of a migration tool failing inside one transaction. The script saves the partial rows, runs the old read and asserts that the rows remain identical afterward. The retained new column still contains the two committed values and one null. That observation is the limited analogue of switching back to code that reads the retained representation; it is not an actual deployment rollback.

At S2, a separate observed old-style write changes row 3's legacy label to South Annex but leaves its normalized value as south. Both columns exist and the new read's non-null check can pass, yet the values disagree. The bridge writer then updates both to repair that particular fixture inconsistency. This repair establishes consistency only for that row and write in the fixture. Concurrent writers, retries, process crashes and any other application path remain untested.

Use expansion to preserve a possible fallback, not to declare safety

The current Prisma expand-and-contract guide describes adding a replacement column, migrating data and removing the old representation when consumers no longer use it. The current route discusses Prisma ORM 8's release candidate and links a separately supported v7 guide. Their command and transaction details differ; this article does not execute or reproduce either workflow.

A retained old column gives you an option only if its contents remain suitable for the fallback code. Define which representation is authoritative in each phase, how writes maintain the other and how drift is detected. An old writer that does not know the new field may require a compatibility strategy before new readers are enabled. Merely adding the field does not solve that coordination problem.

Before enabling a new reader, examine completion and correctness separately. A zero-null count may show that every row has some value, but not that the mapping is correct. In the fixture, non-null values did not detect the later stale write. Use checks appropriate to the transformation and keep ambiguous mappings or exceptions visible rather than inventing a default to make the backfill look complete.

Delay contraction until the consumers and fallback assumptions have been reviewed. Record which code versions, jobs and integrations still depend on the old shape and what evidence supports retiring them. A planned rollback window is an organizational decision, not a universal number of hours. Once the old representation is removed, the previous code may no longer be a valid fallback.

A printmaking workbench preserves an original block and separate altered copies, showing that reversing a mechanism cannot reconstruct every prior detail.

Worked recovery decision: separate a stopped backfill from lost information

The fictional Wren team applies the fixture's lessons to a proposed label migration. Engineer Selene owns the application transition; database owner Hugo owns the data-change review; incident decision owner Nadia coordinates response under the team's actual process. These roles and the following record are invented. No real incident, migration, traffic pause or database action occurred.

The authored scenario stops with an incomplete committed backfill analogous to S1. Some rows have a new value and one remains unset. Nadia keeps the strict new reader disabled. Selene retains the legacy-reading bridge path; Hugo asks for the exact committed boundary and mapping exceptions before authorizing further data work. They do not drop the new column simply to make the schema resemble yesterday's deployment.

Decision field Completed fictional response record Remaining evidence or authority
Immediate application path Keep the new reader off and use the reviewed legacy-reading bridge path for this scenario Selene must verify actual binary/schema compatibility and any other writers; the toy matrix is not that evidence
Data state Retain both fields and preserve the committed-row record; classify the backfill as incomplete Hugo owns identifying the committed row identifiers, mapping exceptions and approved restart behavior before any further data change
Legacy write risk Do not assume old-only writers maintain the normalized field Selene and Hugo need an approved write-consistency approach; a read-only fallback result is insufficient
Proposed next data action Prefer evaluating a bounded repair-forward continuation while the old values remain available No retry, re-run or production SQL is authorized by this written plan
Escalation boundary If legacy data is already lost or cannot satisfy fallback semantics, treat that as a separate recovery decision Nadia seeks the appropriate data/operations approval; do not label it a routine application rollback

A later local fixture branch demonstrates why that last boundary matters. After dropping label, the script re-adds a nullable field with the same name. Existing rows contain nulls there; the old read's explicit assertion still fails. Recreating the shape did not recreate its contents. SQLite's ALTER TABLE documentation describes dropping a column as removing it and purging its associated data, subject to documented schema restrictions.

Copying the normalized values back gives readable text, but not the prior representation. The fixture's later row 1 value North New becomes north new; capitalization is lost. Earlier outer-space and case distinctions also cannot be inferred from normalized text alone. If another retained source can reconstruct a particular value, verify that mapping and its coverage. Do not equate a populated field with restored original information.

The script also creates an in-memory backup before a later bridge write. The backup's row 1 contains North Annex, while the later current value is North New. This checks a time-point difference, not a backup-service restore or point-in-time recovery procedure. Returning to that earlier copy alone would omit the later write; preserving later work requires a separately verified reconciliation or replay path.

Nadia's completed fictional disposition is: “The old representation remains available in the stopped-backfill branch, so investigate repair forward before considering destructive reversal. If recovery from an earlier copy becomes necessary, identify the cutoff, later writes, reconciliation method and approving owner first. We have not demonstrated the real environment's restore time or acceptable data loss.” No successful production recovery or later decision is invented.

Make both paths reviewable before the change

Your change plan should name the application version for each state, the read/write contract, backfill verification and the contraction gate. Beside it, keep the data path: what committed, what information the transformation discards, where recoverable evidence exists and which later writes a restore could affect. A backup timestamp can be reassuring while leaving the difficult question unanswered: which later writes would be missing? Keep that question beside the recovery reference rather than discovering it during the incident.

Rehearse the relevant failure boundaries in an approved environment with representative permitted data. Check transaction behavior, constraints, jobs, load and recovery procedures for the actual engine and versions. The tiny SQLite fixture covers none of those production properties. Its passing assertions demonstrate only the stated local rows and simplified probes.

At review, ask two questions independently: “Can this code version operate correctly against the database state we will leave?” and “What approved action handles the schema and data changes already made?” If either answer is missing, retain the gap instead of replacing it with a rollback button. LandOffer.ai publishes related engineering guidance; use your actual change and incident processes to authorize the next action.

Sources and Further Reading