Lakebase Postgres branching creates an isolated, copy-on-write clone of your database in seconds. Run a migration on the branch, check the result, then keep the branch as a preview environment or delete it. The parent branch never sees the change.
How branching works
Creating a branch doesn't copy data. The branch starts as a pointer to the parent's storage, and writes to the branch are stored as a delta. The parent is unaffected, and branch creation adds no load to its compute. A child branch's storage is billed at the smaller of the changes you make on it or the logical data size (storage billing).
Create a branch from the CLI (use your default branch name as the parent: production for Console-created projects, main for projects created with the CLI or API):
neon branches create --name test-migration --parent productionGet a connection string for that branch:
neon connection-string test-migrationRun your migration against that connection string. If it breaks something, delete the branch:
neon branches delete test-migrationIf it works, apply the same migration to production through your deploy process. Neon doesn't merge branch data back into the parent.
A typical workflow
- Create a branch from your production branch.
- Apply the migration on the branch with your tool of choice (Drizzle, Prisma, Alembic, raw SQL).
- Run your test suite against the branch's connection string.
- If anything is wrong, reset the branch to its parent with
neon branches reset test-migration --parentand try again. The connection string stays the same. - Once tests pass, apply the migration to production through your usual deploy process.
Automate it in CI
Neon's GitHub Actions can create a branch when a pull request opens and delete it when the PR closes, so CI runs against a copy of production data without touching production.
When to use a schema-only branch
If your production data contains PII, use a schema-only branch. It copies the database structure without any rows. A schema-only branch is a new root branch, so it counts toward your plan's root branch allowance, has a per-branch storage cap on paid plans, and can't be reset from a parent.
What other providers offer
- Aurora has database cloning, which also uses a copy-on-write protocol. A clone shares storage pages with the source and diverges as either one changes. Each clone is a new DB cluster with at least one DB instance that you pay for, and there's no built-in PR workflow.
- RDS for Postgres has no copy-on-write clone. The usual pattern is restoring a snapshot to a new instance, which provisions a new server and materializes the data. Blue/Green Deployments create a green copy of production that stays in sync, let you test changes on it, and then switch over. They're built for rolling out a change to production rather than for throwaway test environments.
- Supabase offers branching tied to Git pull requests. Preview branches start from your migrations and
seed.sql, without production data. Dashboard branches (public alpha) can copy production data if the project has the PITR add-on; that copy uses a larger disk and matches the project's compute size.
To test a migration against a copy of production data without first copying the whole database, Lakebase Postgres branches and Aurora clones both use copy-on-write storage. On Neon, branch compute is billed per CU-hour and scales to zero when idle.

See patterns for per-PR branches, preview environments, and recovery from bad migrations.








