HeadlinesBriefing favicon HeadlinesBriefing.com

Postgres Schemas for PR Previews

DEV Community •
×

A developer argues that teams should stop using database branching services like Neon for pull request previews and instead use PostgreSQL schemas. The approach creates a separate schema per PR number within a single database, running migrations in isolation during the build process. This eliminates vendor lock-in and simplifies the stack.

This method leverages a 20-year-old Postgres feature, configuring ORMs like Prisma or MikroORM to connect via a schema parameter. A GitHub Action cleans up schemas when PRs close. It's a practical solution for teams already using Postgres, trading some isolation for portability and control.

While not perfect for massive scale, this pattern offers a compelling alternative for smaller teams. The key insight is that modern ORMs already support schema switching, making the setup straightforward. It represents a shift toward leveraging existing database capabilities over adopting new, specialized services for common development workflows.