---
title: "Moving data while two application releases share one database | Proofline"
description: "During a rolling deploy, the release you are replacing and the release you are shipping read and write the same tables."
url: https://proofline.sh/learn/data-migration-across-service-versions/
---

[Learning center](/learn/)

# Moving data while two application releases share one database

During a rolling deploy, the release you are replacing and the release you are shipping read and write the same tables. After a rollback, the older one does so again. A schema change can be made compatible with both in one migration. Moving data from one shape to another takes several releases, because every row has to reach the new shape while the old release keeps writing the old one. This collection follows one such move from start to finish and shows, at each step, the check that tells you the data converged and the limit on rolling back.

Breaking migrations The Proofline team November 22, 2026 7 min read

## The running example

An `orders` service stores an order's status in a lowercase text column, `status`. The team wants a new column, `state`, with a stricter set of uppercase values, and eventually wants `status` gone. Three releases take part:

| Release | Reads | Writes |
| --- | --- | --- |
| `2026.11.3` | `status` | `status` |
| `2026.11.4` | `state` | `status` and `state` |
| `2026.11.5` | `state` | `state` |

During each rollout two neighboring releases run at once, and the previous one stays available as a rollback target. We ran every lab on PostgreSQL 16.15 with Python 3.11 and psycopg 3.2. Timings come from a laptop-sized machine and only compare one method with another on the same data.

## Know who still writes the old shape

The move cannot finish while something still writes `status` without `state`. That writer is not always the previous release of the service: batch jobs, exports and other services connect too.

-   [Tag database connections with the release that opened them](/learn/postgres-which-release-is-connected/) shows how `application_name` and a small trigger attribute every write to the old column.
-   [Why a data step in a schema migration misses rows](/learn/data-migration-in-schema-migration-file/) shows the old release writing rows after the migration's `UPDATE` has finished.

## Backfill the rows that already exist

A backfill copies existing rows into the new shape while both releases keep writing. Each of these labs shows a backfill that completes without an error and leaves rows wrong.

| Question | Lab | What went wrong without it |
| --- | --- | --- |
| How large should each batch be? | [Backfill in batches so the application never waits on row locks](/learn/postgres-backfill-batch-row-locks/) | One `UPDATE` made an application write wait 3,664 ms |
| How do I walk the table? | [Batch a backfill by key, not by OFFSET](/learn/postgres-backfill-keyset-pagination/) | `OFFSET` over unfilled rows left 500,000 of 1,000,000 unfilled |
| Where should the new value be computed? | [Compute the backfilled value in SQL, not in the job](/learn/postgres-backfill-read-modify-write-race/) | A cancelled order was written back as `PAID` |
| Can a copy resume from the highest ID it saw? | [Why a watermark copy misses a late commit](/learn/postgres-backfill-watermark-late-commit/) | Row 3 never reached the new table |
| Can the backfill run in one transaction? | [Commit each batch so vacuum keeps up](/learn/postgres-backfill-long-transaction-xmin/) | 20,000 dead rows in another table could not be removed |
| What else fires when a row is backfilled? | [Keep a backfill from firing update triggers](/learn/postgres-backfill-side-effect-triggers/) | 100,000 `order.updated` events and a new `updated_at` on every row |

## What the backfill costs the database

| Question | Lab |
| --- | --- |
| Should the new column's index exist before the backfill? | [Create the new column's index after the backfill](/learn/postgres-backfill-hot-updates-index-order/) |
| Why did the table double in size? | [Vacuum between backfill batches to keep the table from doubling](/learn/postgres-backfill-dead-tuples-vacuum/) |
| Why did the replica stop showing new rows? | [Backfill replica lag comes from replay conflicts too](/learn/postgres-backfill-replica-lag/) |

## Keep both shapes in step while both releases write

Rows the old release writes after the backfill starts need a path into the new shape too, and a rollback needs a path back.

| Question | Lab |
| --- | --- |
| Application dual writes or a trigger? | [Use a trigger when the old release must keep filling the new column](/learn/postgres-sync-trigger-old-writer/) |
| Can the new column start as a generated column? | [Use a generated column as the first step of a column change](/learn/postgres-generated-column-transition/) |
| How does the old column stay current for a rollback? | [Sync two columns both ways while the old and new releases write](/learn/postgres-two-way-sync-trigger-conflict/) |
| How do I move a counter that keeps changing? | [Move a counter to a new table without losing increments](/learn/postgres-counter-migration-deltas/) |
| Can the backfill skip triggers with the replication role? | [A backfill with session\_replication\_role = replica skips foreign keys](/learn/postgres-session-replication-role-foreign-keys/) |
| Does a new version column see the old release's writes? | [Add an optimistic lock version that the old release cannot bypass](/learn/postgres-optimistic-lock-version-old-writer/) |
| How do I keep a Redis copy in step with PostgreSQL? | [Write to PostgreSQL and Redis without letting them drift](/learn/dual-write-postgres-redis-outbox/) |

## Move the readers

-   [Why COALESCE(new, old) shows a value the user removed](/learn/coalesce-new-old-column-fallback/) shows the fallback read bringing back a cleared value, and a marker column that avoids it.
-   [Compare old and new reads on live traffic](/learn/shadow-read-comparison/) shows what shadow reads find and what they miss.
-   [Move reads to the new data source by user, not by request](/learn/switch-reads-by-stable-bucket/) keeps each user on one source while the share grows.
-   [Introduce soft delete while the old release still reads the table](/learn/postgres-soft-delete-old-release/) shows a new column that changes what every old query means.

## Values whose meaning or precision changes

Some conversions succeed on every row and still change what a value means. Each of these labs shows one.

| Change | Lab | What went wrong without it |
| --- | --- | --- |
| One column split into two | [Test a column split for rollback and for meaning separately](/learn/split-column-round-trip-test/) | Nine of nine names round-tripped; seven needed review |
| Integer cents to a decimal amount | [Convert prices between cents and decimals without losing a cent](/learn/integer-cents-to-decimal-amount/) | Truncation lost a cent on 65,624 of a million prices |
| `timestamp` to `timestamptz` | [Move from timestamp to timestamptz while old writers send local times](/learn/postgres-timestamp-to-timestamptz-writers/) | Two pods stored one booking an hour apart |
| Timestamps read by JavaScript | [A JavaScript release that writes a timestamp back drops its microseconds](/learn/javascript-timestamp-microseconds-write-back/) | An optimistic lock check matched no row |
| IDs above 2⁵³ | [64-bit IDs that a JavaScript consumer rounds to another row](/learn/javascript-bigint-ids-json/) | An update changed the neighboring event |

## Documents, caches and messages

The same two releases share more than tables.

-   [The old release deletes JSON fields it does not know](/learn/json-unknown-fields-dropped-old-release/) shows a whole-document save erasing a new field, and the one-level limit of `||`.
-   [Migrate JSON documents on read, and finish with a backfill](/learn/lazy-migration-on-read-version-field/) shows 10% of documents still on the old version after 30 days of reads.
-   [Change a cached object's format during a rolling deploy](/learn/redis-cache-format-versioned-keys/) and [keep old and new cache entries consistent when both releases write](/learn/redis-cache-invalidation-across-versions/) cover Redis keys during a rollout.
-   [Change a queue message so old and new consumers both handle it](/learn/queue-message-schema-consumer-first/) and [new-format messages still in the queue after a rollback](/learn/queued-messages-after-rollback/) cover messages that outlive the release that sent them.

## Move a table to another database

-   [Set sequences before cutting over to a logically replicated database](/learn/postgres-logical-replication-sequences-cutover/) shows the first insert after a cutover failing on a sequence that was never replicated.
-   [A column added during logical replication stops the subscriber](/learn/postgres-logical-replication-ddl-subscriber/) shows the order for schema changes while a move is in progress.
-   [Freeze writes before a cutover, including connections already open](/learn/postgres-read-only-cutover-existing-sessions/) shows why `default_transaction_read_only` is not a freeze.

## Prove the shapes converged and stop writing the old one

-   [Find every backfill mismatch with IS DISTINCT FROM](/learn/postgres-backfill-reconciliation-is-distinct-from/) counts the rows that differ, including the ones a `<>` comparison misses because a side is null, and separates rows still being written from rows that stayed wrong.
-   [Compare two tables in chunks with a checksum](/learn/postgres-chunked-table-checksum/) narrows a million-row comparison to the two ranges that differ.
-   [Find every query that still reads the old column](/learn/postgres-find-readers-of-old-column/) finds readers in the statement statistics and makes hidden ones fail in staging.
-   [What a rollback loses after one value became many](/learn/rollback-after-one-to-many-split/) counts the rows the old shape cannot hold.
-   [Run the previous release's tests against the new schema](/learn/previous-release-tests-new-schema/) catches a migration that ships a release too early.
-   [How long the old column has to stay](/learn/expand-contract-timeline-calculation/) turns rollout, rollback, job, queue and cache clocks into a date.
-   [Decide when to stop writing the old column](/learn/when-to-stop-dual-writing/) lists the evidence to collect first and shows what a rollback reads once the old column stops receiving writes.

## Related guides

The changes to the schema itself have their own labs. [Which PostgreSQL migration needs a rehearsal](/learn/postgres-migration-rehearsal/) covers lock queues, table rewrites and constraints. [How to test a PostgreSQL migration before rolling back the app](/learn/postgres-migration-rollback/) shows the read side of a column rename. The [migration review checklist](/learn/database-migration-review/) gives the expand and contract sequence that this collection fills in.

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Which PostgreSQL migration needs a rehearsal before the next deploy](/learn/postgres-migration-rehearsal/)
    
    Breaking migrations The Proofline team November 20, 2026 4 min read
    
-   ### [PostgreSQL migration review for rolling deployments](/learn/database-migration-review/)
    
    Breaking migrations The Proofline team October 7, 2026 7 min read
