A clean database for every test run
Create a Postgres branch when the pipeline starts, run migrations and tests against it, and delete it when the job ends. Each run tests against an untouched copy of your data.
A fresh copy every run
Each run tests against an untouched copy of your data.
Parallel jobs
Each job gets its own branch. Nothing is shared.
Deleted at the end
The last step removes the branch.
Flaky tests often start in the database
A shared test database turns CI into a queue. Jobs wait for each other, or they run together and trip over each other’s rows. Cleanup scripts miss a table, a migration from one branch leaks into another branch’s run, and tests fail for reasons that have nothing to do with the code under test.
Mocking the database avoids the queue but stops testing what production actually runs.
Create, test, delete. Every run.
Create
The first step creates a branch from your baseline: production, staging, or a masked copy. It copies no data, so it is ready in about three seconds.
Migrate and test
Apply pending migrations, seed if you need to, run the suite. Integration tests hit real Postgres with the real data shape.
Delete
The last step deletes the branch. Nothing carries over to the next run.
Works with the CI you already run
Copy the workflows
GitLab, CircleCI, Buildkite, Jenkins
Agents run the suite before you review
Your agent can run the whole workflow
Connect the Xata MCP server or install the CLI, and your coding agent can create branches, apply migrations and read schema without touching production.
- Claude Code
- Cursor
- Codex
- VS Code (Copilot)
- Windsurf
- Cline
- OpenCode
- Zed
- Read the guide
Xata for coding agents
CLI, MCP and agent skills in one place.
- Connect MCP
MCP server
Setup for every supported client.
No bill for cancelled jobs, no exposed data
- Learn more
Cancelled jobs do not leave a bill
If a job is cancelled before its delete step, the leftover branch can scale to zero until the cleanup workflow removes it.
- Learn more
Test against real data without exposing it
If production holds personal data, branch CI runs from a masked copy. The distributions stay realistic and the values do not.
More branching workflows
- Learn more
One branch per pull request
Test every migration before it merges.
- Learn more
One branch per preview
A database for every Vercel and Netlify preview.
- Learn more
Database Branching
How Xata branches Postgres.
Give every test run its own database
Stop sharing a test database. Branch it per run and delete it when the job ends.