← All selected work
Developer infrastructure
Portable database isolation for every preview deployment
A schema-per-branch workflow that gives each pull request isolated Postgres state without vendor lock-in.
Primary evidencePer PR
isolated database state
Situation
What the system needed to change
Preview deployments needed realistic database migrations and state without allowing one branch to affect another or forcing a database-vendor change.
Constraints
The boundaries mattered.
- 01
The approach had to work with an existing Postgres database
- 02
Preview schemas needed deterministic cleanup
- 03
Migrations and runtime queries had to resolve the same schema
Decisions
The important engineering choices
- Derived a sanitized schema name from the pull request or branch
- Configured both ORM schema and Postgres search path
- Ran migrations during preview builds
- Removed the schema automatically when the pull request closed
Outcome
What the work left behind
- Portable isolation across Vercel preview deployments
- No data leakage between active pull requests
- Explicit tradeoffs for connection limits, extensions, and failed cleanup