Branch a database like code.
A branch is a consistent copy of a live database, made while the parent keeps taking writes, or of any past point in the S3 archive. Work on it, diff it against the parent, then merge it back in one transaction, reset it, promote it or drop it.
Branch production, change it, merge it back
A branch is a consistent copy of a live database, made while the parent keeps taking writes. It keeps a merge base, so a three-way diff shows exactly what a merge would do.
- 1Production keeps writing
prod takes writes the whole time; nothing pauses.
- 2CREATE BRANCH preview
A consistent copy as of now, with its roles, indexes and partitions, and a merge base.
- 3The branch diverges
A migration adds a column on preview and rewrites some rows.
- 4SHOW BRANCH DIFF
Per table: schema changes, inserts, updates, deletes, and rows both sides changed.
- 5MERGE BRANCH
Applied to prod in one transaction. ON CONFLICT FAIL refuses if both sides changed a row.
- 6Or reset, promote, drop
RESET re-copies the parent; PROMOTE swaps them by name; DROP throws the branch away.
Six statements
CREATE DATABASE dev TEMPLATE prod is PostgreSQL's spelling of the same copy. A branch is an ordinary database: connect to it by name; its roles, sequences, indexes and partitions came with it.
CREATE BRANCH preview FROM prod; CREATE BRANCH incident FROM prod AS OF TIMESTAMP '2026-11-19 10:00+00'; SHOW BRANCH DIFF preview; MERGE BRANCH preview INTO prod ON CONFLICT FAIL; RESET BRANCH preview; PROMOTE BRANCH preview;
Three-way merge, with conflicts you can see
A branch keeps its merge base. SHOW BRANCH DIFF reports, per table, the schema changes, inserts, updates and deletes a merge would apply, and every row both sides changed. MERGE applies them in one transaction: fail on a conflict, or let the branch or the parent win.
- Schema changes replayed in order
- Rows matched by key, three ways
- ALLOW DROP must be said to drop a table
- Branches of branches: a tree, shown in SHOW BRANCHES and rdb_studio
What teams do with it
- A database per pull request, merged with the code
- Rehearse a migration on yesterday's data, then promote
- Branch from before an incident, copy back only what was lost
- Hand analysts a copy that cannot touch production