Fast local PostgreSQL database branching for migrations, schema testing, and isolated development workflows
open sourceMITself-hostablefree
dbfork is a Go CLI that branches a local Postgres development database with Postgres's own CREATE DATABASE ... TEMPLATE, a server-side copy that takes seconds instead of the minutes a dump and restore takes. It tracks branches in local state, prints a branch's connection string, writes the active branch to a .dbfork file in the project, and diffs a branch's schema (tables, columns, indexes) against its source. Each branch is a full copy inside the same Postgres instance, so disk use grows with every branch, and it terminates idle sessions on the source to clone it.
Problems it solves
- test a migration on a copy of my local dev database and throw it away after
- pg_dump and restore takes minutes every time I want a fresh copy of my dev database
- give each feature branch its own local Postgres database
- see how a branch's schema differs from the main dev database
- switching git branches leaves my dev database with the wrong migrations applied
- clone a local Postgres database in seconds without Docker or a cloud account
Features
- branches with CREATE DATABASE ... TEMPLATE
- schema diff against the source
- active branch per project directory
- connection strings as DSN, env or psql
Capabilities
| Has a command line tool | plan not known |
|---|
Alternatives
The same job
These do what dbfork does.
- pgbranch Git branching for your PostgreSQL database
- DBLab Engine Blazing-fast PostgreSQL cloning and branching for dev/test environments and CI
- 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.