Database branches
Create a copy of a project for a pull request or a risky change, run your migrations there first, and understand what a branch copies, what it costs and when it disappears.
A branch is a new project made from a copy of an existing PostgreSQL project. It has its own URL, API keys and database, so a migration, a policy or a preview deployment can be tried on it without touching the source.
Prerequisites#
-
A linked project:
aura link <project-id>. -
The example schema, installed with the service role key of the project:
export AURABASE_SERVICE_ROLE_KEY=aura_sk_… aura db seed --example docsIt creates
profiles,orgs,org_members,posts,todos, the viewopen_todosand the functiontodo_count(p_user uuid). See Example schema. -
aura login: theaura branchcommands use your account, not a project key. Creating or deleting a branch takes thedeveloperrole in the organization; listing takesviewer.
The examples apply a migration wf_br_base to the project, create the branch wf-br-review and the tables wf_br_items and wf_br_notes, and write branch.json and a folder branch-work; the Clean up block removes them. sed replaces the timestamp of migration file names with YYYYMMDDHHMMSS.
aura db migration new wf_br_base > /dev/null
echo "create table wf_br_items (id bigint generated always as identity primary key, name text not null);" > "$(ls aurabase/migrations/*_wf_br_base.sql)"
aura db push 2>&1 | sed -E 's/[0-9]{14}_/YYYYMMDDHHMMSS_/' | grep wf_br
aura db raw "insert into wf_br_items (name) values ('first'), ('second')" ✔ YYYYMMDDHHMMSS_wf_br_base.sql applied
ℹ No results (0 rows).What a branch is#
| Question | Answer |
|---|---|
| Copy or replica? | A copy made at creation. The source is read in one consistent snapshot and copied; nothing flows between them afterwards. |
| What is copied? | Schema (tables, constraints, indexes, enum types, sequences and their values), row level security and policies, functions, triggers, views and materialized views, the privileges of tables and functions, and the rows unless you ask for the schema only (--no-data). |
| What is not? | Auth users, sessions and settings; storage buckets and objects; edge functions, secrets, environment variables and cron jobs; Realtime settings of tables; comments; column privileges; GraphQL activation. The ledger of migrations starts empty (see below). |
| How long does it live? | 72 hours by default, from 1 hour to 30 days (--ttl 1h to --ttl 30d). An expired branch and a failed one are deleted automatically, checked every 30 seconds. |
| What does it cost? | The copy takes time in proportion to the data: on the local test stack, 14 rows took under a second. A branch counts against the active branches of your organization (max_branches: 1 on Free, 10 on Pro, 25 on Team, 2,147,483,647 on Enterprise), not against its projects. |
| Size limit | A branch with rows is refused above 2 GiB of data by default, and a copy stops after 30 minutes. --no-data has no size limit. |
| Which projects? | PostgreSQL projects that are active and not hibernated. A branch cannot be branched. |
A branch is not a backup and not a staging environment kept in sync: create it when you need it, and delete it when the change is merged.
Create a branch#
aura branch create <name> copies the linked project (or --from <id, slug or name>) and waits until the branch is ready, 15 minutes at most by default (--timeout). --json prints what a script needs, keys included; this example stores it in a file and prints everything but the keys:
aura branch create wf-br-review --ttl 2h --json > branch.json
node -e 'const b = JSON.parse(require("fs").readFileSync("branch.json", "utf8"))
console.log(b.branch, b.state, b.status, b.parent_project_id === process.env.PROJECT_ID ? "(copy of this project)" : "")
console.log(Object.keys(b).sort().join(", "))'wf-br-review ready active (copy of this project)
anon_key, branch, expires_at, id, parent_project_id, service_role_key, slug, state, status, urlThe keys are shown once, as for a new project: keep branch.json out of version control, and store the keys as secrets of your CI or preview deployment. Without --json, the command prints a summary, the URL and the keys. --no-wait returns at once with the state provisioning; follow it with aura branch list (provisioning, then cloning, then ready or failed).
Names use letters, digits, ., _, - and /, up to 63 characters, start with a letter or a digit, and are unique among the live branches of a project, whatever the case. The branch project is named <source>/<branch>.
What was copied#
aura branch list shows the branches of the linked project (--all for every branch of the organization, --json for scripts). The JSON holds the report of the copy:
aura branch list --json | node -e 'for (const b of JSON.parse(require("fs").readFileSync(0, "utf8"))) {
const r = b.report
console.log(b.name, b.state, b.with_data ? "with rows" : "schema only")
console.log(`${r.tables} tables, ${r.rows} rows, ${r.views} view, ${r.functions} function, ${r.policies} policies, ${r.triggers} triggers`)
for (const x of r.not_cloned) console.log("not cloned:", x)
}'wf-br-review ready with rows
6 tables, 13 rows, 1 view, 1 function, 2 policies, 0 triggers
not cloned: auth users, sessions and auth settings
not cloned: storage buckets and objects
not cloned: edge functions, secrets, environment variables, cron jobs
not cloned: realtime table settings
not cloned: table and column comments (including pg_graphql directives)
not cloned: column-level privileges
not cloned: pg_graphql activation (run `aura projects graphql-enable` on the branch)The rows are the source's, personal data included: there is no anonymization. Branch a staging project rather than production when the copy must not hold real data. Rows owned by users point to no user of the branch, since users are not copied: create test users on the branch (Seed a project with test data).
Try a migration on the branch#
A branch is a project: link a folder to it and use the usual commands with its service_role key. This example writes the aurabase.toml of the branch from branch.json in a separate folder, with a copy of the migrations:
mkdir -p branch-work && cp -r aurabase branch-work/
node -e 'const b = JSON.parse(require("fs").readFileSync("branch.json", "utf8"))
console.log(`[project]\nname = "branch"\nproject_id = "${b.id}"\nproject_url = "${b.url}"`)' > branch-work/aurabase.toml
cd branch-work
export AURABASE_SERVICE_ROLE_KEY=$(node -pe 'JSON.parse(require("fs").readFileSync("../branch.json", "utf8")).service_role_key')
aura db raw "select count(*) as items from wf_br_items"
aura db status | sed -E 's/[0-9]{14}_/YYYYMMDDHHMMSS_/' | grep wf_br items
─────
2
ℹ 1 row(s).
YYYYMMDDHHMMSS_wf_br_base.sql PENDING -The table and its rows were copied, but the ledger of migrations is empty: the branch does not know that wf_br_base ran. A plain aura db push would run it again and fail with relation "wf_br_items" already exists. Record the migrations the source already ran, then push the new one:
cd branch-work
export AURABASE_SERVICE_ROLE_KEY=$(node -pe 'JSON.parse(require("fs").readFileSync("../branch.json", "utf8")).service_role_key')
for f in aurabase/migrations/*.sql; do aura db migration repair "$(basename "$f")" --applied > /dev/null; done
aura db migration new wf_br_notes > /dev/null
echo "create table wf_br_notes (id bigint generated always as identity primary key, item_id bigint references wf_br_items (id));" > "$(ls aurabase/migrations/*_wf_br_notes.sql)"
aura db push 2>&1 | sed -E 's/[0-9]{14}_/YYYYMMDDHHMMSS_/' | grep wf_br ℹ YYYYMMDDHHMMSS_wf_br_base.sql (already applied)
✔ YYYYMMDDHHMMSS_wf_br_notes.sql appliedThe source project did not change:
aura db table list | grep -c 'wf_br_notes' || true0When the migration works on the branch, add it to your migrations and apply it to the source with aura db push, from your usual folder. To run this in CI for each pull request, see Preview databases per pull request.
Limits and refusals#
The limit counts the live branches of the organization; a branch whose creation failed does not count. Past it, and from a branch, creation is refused at once:
aura branch create wf-br-second --no-wait 2>&1 | grep Error || true
branch_id=$(node -pe 'JSON.parse(require("fs").readFileSync("branch.json", "utf8")).id')
aura branch create wf-br-nested --from "$branch_id" --no-wait 2>&1 | grep Error || trueError: [403] BRANCH_LIMIT_REACHED: Your plan free allows 1 active branch(es) per organization. You already have 1. Delete one with `aura branch delete`, or wait for its TTL.
Error: [400] BRANCH_OF_BRANCH: A branch cannot be branched: create the branch from its parent projectThe copy also refuses a source that it cannot reproduce in full, within seconds of the creation, and deletes the branch project. Measured with a partitioned table in the source:
Error: The branch could not be created: This project uses objects that a branch cannot reproduce yet: partitioned table "wf_br_events", partitioned table "wf_br_events_2026". A branch would be incomplete, so it is refused.
Nothing was left behind: the branch project is removed automatically.| Refused | Message starts with |
|---|---|
| Partitioned and inherited tables, foreign tables, domains, composite and range types, aggregate and window functions, rewrite rules, foreign keys to another schema | This project uses objects that a branch cannot reproduce yet: … |
| Extensions other than those every project has | The source project uses extension(s) the branch database does not have: … |
| More than 2 GiB of data with rows | This project holds about … MB of data, the limit for a branch with data is … MB. Create the branch with --no-data (schema only), or reduce the large tables. |
| A source that is paused, provisioning or hibernated | [409] SOURCE_NOT_ACTIVE |
| A MongoDB project | [400] BRANCH_SOURCE_UNSUPPORTED |
A failed branch stays in aura branch list for 24 hours with its message, then disappears. The schema of the source is read just before the copy: do not change it while a branch is being created.
Delete a branch#
aura branch delete wf-br-review --force
aura branch list✔ Branch 'wf-br-review' deleted (its database is being removed).
» Branches
ℹ No branches.
• Create one with aura branch create <name>Without --force, the command asks for confirmation, and fails in a script (Cannot ask for confirmation: not a terminal. Pass --force instead.). Deleting a branch deletes its database; it cannot be undone. A branch you forget is deleted at the end of its time to live.
In Studio#
The Branches page of a project creates a branch (name, time to live in hours, schema only), lists the branches with their state, expiry and project id, deletes them, and shows the recent failures. On a branch, the page says that it cannot be branched again.
Result#
aura db status | sed -E 's/[0-9]{14}_/YYYYMMDDHHMMSS_/' | grep wf_br
aura db table list | grep wf_br YYYYMMDDHHMMSS_wf_br_base.sql APPLIED 2026-11-23 10:00:00.000000+00
• wf_br_items [RLS]The project kept its own migration and table; wf_br_notes existed on the branch only.
Common errors#
| Message | Cause | Fix |
|---|---|---|
[403] BRANCH_LIMIT_REACHED: Your plan … allows N active branch(es) per organization. | The organization has as many live branches as its plan allows. | Delete one, or wait for its time to live. |
[400] BRANCH_OF_BRANCH | --from names a branch. | Branch its parent project. |
[400] INVALID_BRANCH_NAME: invalid branch name: … | Spaces or other characters, more than 63 characters, //, .., or a final / or .. | Use letters, digits, ., _, -, /. |
[409] BRANCH_NAME_TAKEN | A live branch of the project has that name. | Pick another name or delete the old branch. |
Invalid --ttl '…': a branch lives between 1h and 720h (30d) | The time to live is out of bounds. | Use 1h to 30d. |
Invalid --ttl '…': the unit must be h, d or w (e.g. 72h, 3d, 2w) | Minutes or another unit. | Use hours, days or weeks. |
relation "…" already exists on aura db push to a branch | The branch's ledger is empty. | aura db migration repair <file> --applied for the migrations the source already ran. |
A 400 BAD_REQUEST in French saying that the third segment of the path does not match the project served by the host | NEXT_PUBLIC_AURABASE_URL (environment or .env) still points to the source while aurabase.toml names the branch; the variable wins. | Set it to the branch URL, or unset it. |
Timed out after 900s: the branch is still being created. | The copy takes longer than --timeout. | Follow it with aura branch list; raise --timeout. |
No active branch named '…' for project … | aura branch delete with a wrong name, or a branch already deleted. | aura branch list. |
Clean up#
aura branch delete wf-br-review --force > /dev/null 2>&1 || true
aura db raw "drop table if exists wf_br_items"
for f in aurabase/migrations/*_wf_br_*.sql; do aura db migration repair "$(basename "$f")" --reverted > /dev/null; done
rm -rf aurabase/migrations branch-work branch.json ℹ No results (0 rows).