Branches
A copy of your project with its own database, keys and URL to try a change on, then merge its migrations into main.
A branch is a copy of your project to try a change on: a migration, a feature, a data fix. It has its own database,
its own API keys and its own URL, <server>/b/<name>. When the change works, merge the branch's migrations into main.
Data never moves between them.
forkbase branch create dev # a copy of main's data
forkbase migration push --url http://127.0.0.1:8000/b/dev --service-key "$DEV_SERVICE_KEY"
forkbase branch merge dev --dry-run # what would run on main
forkbase branch merge dev
forkbase branch delete dev --yesOr on the dashboard: the branch switcher in the top bar, and Settings, Branches.
How a branch starts
from | The branch's database |
|---|---|
copy (default) | main's data as it is now: tables, rows, users, buckets, functions, policies |
migrations | an empty database, then main's app migrations applied in order |
- postgres mode: the copy is
pg_dumpof main restored into a new databasefb_br_<name>on the same Postgres server, so the Postgres client tools are needed (see Backups);migrationsneeds only the database. The user indatabase.urlmust be allowed to create databases. - chronos mode: the copy is the engine's backup of main, opened by an engine of the branch's own.
- Main's migrations are the ones in
forkbase.app_migrations. Those pushed before 0.7 kept no SQL, so amigrationsbranch skips them and says so.
A copy is made safe before the branch first serves: main's signing keys, sessions, refresh tokens and MCP tokens are removed (the branch signs its own keys, so main's tokens are refused there and the branch's are refused on main), log drains and agents' webhooks are removed, job schedules are paused, and the branch gets an instance id of its own. Connections sealed with main's secret can't be opened on the branch: add the ones you need there again.
A branch keeps its stored files in its own data folder: a copy has main's buckets and file records, not the files.
Keys and access
Each branch writes its keys to <data>/branches/<name>/api-keys.json; admins read them at
GET /platform/v1/branches/<name>/keys or in the branch's API keys menu. Apps use the branch URL and its anon
key exactly as they use main's.
Through /b/<name>/..., this server's service key and a dashboard member's key are passed on as the branch's service
key, after the member's role is checked against the path. Any other key goes through as it is, for the branch to
check. Realtime's WebSocket is passed through the same way.
Merge
POST /platform/v1/branches/<name>/merge (forkbase branch merge) reads the branch's migrations and applies, in
version order, each one main doesn't have, through main's own migrations API: each in a transaction, recorded on main.
- A version on both with the same SQL is skipped (
already_on_main). - A version on both with other SQL stops the merge with a
409: nothing after it runs. {"dry_run": true}runs each on main and rolls it back.main_onlylists main's migrations the branch doesn't have: reset the branch to take them.- Each migration merged keeps where it came from:
merged_from(the branch) andapplied_by(who merged: a member's email, orservice_role) inGET /platform/v1/migrations. The branch shows its last merge asmerged_atand how many merges applied something asmerges.
Reset and delete
POST /platform/v1/branches/<name>/reset {"confirm": true} stops the branch, makes its database again the way it
was first made (a new copy, or main's migrations), and starts it. Its data and users are replaced, and its API keys
change. DELETE /platform/v1/branches/<name> stops it and deletes its database, folder and keys. Main still
remembers it: GET /platform/v1/branches lists it under deleted, with deleted_at and deleted_by (a member's
email, or service key), when it was made and last merged. A name can be used again; each branch made is its own
entry.
API
| Method | Path | |
|---|---|---|
| GET | /platform/v1/branches | main and every branch: name, from, status, url, created_at, created_by, merged_at, merges; deleted: branches deleted, newest first, with deleted_at and deleted_by too |
| POST | /platform/v1/branches | {"name": "dev", "from": "copy"} (branch_name works too) |
| GET | /platform/v1/branches/<name> | one branch, with merged_at and merges |
| DELETE | /platform/v1/branches/<name> | |
| POST | /platform/v1/branches/<name>/reset | {"confirm": true} |
| POST | /platform/v1/branches/<name>/merge | {"dry_run": false} |
| GET | /platform/v1/branches/<name>/keys | admins: url, anon, service_role |
Branches are made on the main server only, not inside a project or another branch. At most 50.
Something wrong or missing? Edit this page on GitHub or open an issue.