Solutions
A preview database for every pull request
Create a branch of your database when a pull request opens and delete it when the pull request closes. Each preview starts from your real data and runs on its own compute, so migrations and tests never touch the main branch.
How it works
01
Branch when the pull request opens
Your CI job calls the Open API with an API key and creates a branch from your main branch. A branch is a copy-on-write fork of its parent, ready in seconds whatever the database size.
curl -X POST "https://relyt.one/api/v1/projects/$PROJECT_ID/branches" \ -H "Authorization: Bearer $RELYT_API_KEY" \ -H "Content-Type: application/json" \ -d "{\"name\":\"pr-$PR_NUMBER\",\"parentBranchSlug\":\"$MAIN_BRANCH_SLUG\"}"02
Point the preview at the branch
Every branch gets its own primary compute. List the project's branches, wait until the new compute's status is READY, and use its host for the preview's migrations, tests and app.
curl "https://relyt.one/api/v1/projects/$PROJECT_ID/branches" \ -H "Authorization: Bearer $RELYT_API_KEY"03
Delete it when the pull request closes
One more call deletes the branch and its compute. The main branch is never changed.
curl -X DELETE "https://relyt.one/api/v1/projects/$PROJECT_ID/branches/$BRANCH_SLUG" \ -H "Authorization: Bearer $RELYT_API_KEY"
What you get today
Real data, not fixtures
A branch starts with the full data set of its parent. It shares unchanged data with the parent, so only the changes a preview makes take up new storage.
Its own compute
Queries on a preview run on the branch's compute, not on the main branch's. An idle compute can suspend and resume on the next connection without touching your data.
Scriptable from any CI
Create, list, rename and delete branches with the REST Open API and an API key. Branch names are unique within a project, so a job that runs twice for the same pull request gets a 409 instead of a second branch.
Good to know
- Relyt One installs nothing in your repository: the calls run in your own CI workflow, for example a GitHub Actions job, with the API key stored as a secret.
- A branch that still has child branches cannot be deleted, and the primary branch cannot be deleted at all, so create previews from the main branch and delete them before their parent.
Other solutions
Try it on the Free plan.
Sign in with GitHub or Google, create a project and an API key, and run the calls above. No credit card required.