Skip to content

The CollectionInstrument No. 05

dbfork

Branch your database like you branch your code.

The Problem

Testing a migration against realistic data means pg_dump and restore — usually two to five minutes for a 1 GB database, every single time. So developers test against stale fixtures, and the migration meets real data for the first time in production.

The Insight

Postgres already knows how to copy a database without a dump: CREATE DATABASE … TEMPLATE. The missing piece was a state file and a decent UX.

The Instrument

dbfork wraps the template mechanism in a branching workflow: init, create, list, connect, diff, use, drop. A 1 GB clone typically lands in 1–3 seconds, and ~/.dbfork/state.json tracks which fork is which.

It is honest about its limits: active writers block a clone, forks are whole-database copies, and diff is schema-only in v1. An instrument that says less than it knows, but never more.

Seconds, not minutes

$ dbfork create feature-migration

✓ Created branch 'feature-migration'

Connect: dbfork connect feature-migration

$ dbfork diff feature-migration

Tables

+ audit_events

~ users

+ column last_login_at (timestamp with time zone)

+ index users_last_login_at_idx

Representative session in dbfork’s output format. The 1–3 s clone is the README’s estimate, not a published benchmark.

Spec

Mechanism
CREATE DATABASE … TEMPLATE
Clone time
README estimate: 1 GB in 1–3 s vs 2–5 min for pg_dump + restore
Commands
init · create · list · connect · diff · use · drop
State
~/.dbfork/state.json
Known limits
Active writers block clones · whole-DB copies · schema-only diff
Install
go install · release binaries
Quick start
go install github.com/Meru143/dbfork/cmd/dbfork@latest

The Outcome

dbfork v0.1.1 shipped on 21 March 2026 with binaries for Linux, macOS and Windows. Built so migrations get rehearsed against real-shaped data before opening night, without the two-minute excuse for skipping the rehearsal.