Git branching for your PostgreSQL database
open sourceMITself-hostablefree
pgbranch gives a local Postgres development database git-style branches: pgbranch branch snapshots the database as a template database, and pgbranch checkout drops the working database and recreates it from that snapshot, with no dump or restore. A git hook can switch the database when you check out a git branch. It also diffs schemas between branches, merges schema changes (beta), migrates a database by logical replication, and can be used as a Go library. Each snapshot is a full file-level copy, and one working database switches between branches rather than running them side by side.
Problems it solves
- I switch back to main and my database still has the feature branch's migrations applied
- switch my dev database automatically when I check out a git branch
- snapshot my local Postgres database and go back to it instantly
- dropping and re-seeding the dev database every time I change branches is slow
- compare the schema of two versions of my dev database
- keep one local database per git branch without remembering connection strings
Features
- branch and checkout with template databases
- git hook for automatic switching
- schema diff
- schema merge (beta)
- migration by logical replication
- remotes
- usable as a Go library
Capabilities
| Has a command line tool | plan not known |
|---|---|
| Has official SDKs | plan not known |
Alternatives
The same job
These do what pgbranch does.
- DBLab Engine Blazing-fast PostgreSQL cloning and branching for dev/test environments and CI
- dbfork Fast local PostgreSQL database branching for migrations, schema testing, and isolated development workflows
- pgoverlay Instant, writable copy-on-write branches of your real Postgres, self-hosted on plain Docker or Kubernetes. No ZFS required.
- db-branch Instant database branches for MySQL and PostgreSQL, on your own servers
- Xata Open source, cloud native, Postgres platform with copy-on-write branching and scale-to-zero
- RiftDB Instant, copy-on-write database branches for Postgres. Self-hosted. Every PR gets its own database.