BranchBase
Zero-config, Git-native local database branching for PostgreSQL, MySQL, SQLite, and MongoDB.
Stop dropping your local database every time you switch Git branches.
Problem Context: Git vs. Local Database Friction
Every developer working with Docker, local PostgreSQL, MySQL, or SQLite has suffered this loop:
1. You work on `feature/checkout-v2`.
└── Ran migrations: added table `stripe_orders`, added column `users.billing_tier NOT NULL`.
2. Urgent production bug alert! You run:
└── `git checkout main`
3. You start the app or run tests on `main`.
4. CRASH:
└── ActiveRecord::PendingMigrationError / PrismaClientKnownRequestError:
"column users.billing_tier does not exist" or "schema mismatch detected".
How developers waste hours today:
- The Nuclear Option:
docker compose down -v && docker compose up -d
(Loses all test seeds, logins, and mocked state. Takes minutes to re-seed). - The Manual Rollback Dance: Trying to rollback migrations on
feature/checkout-v2before switching, only to lose experimental test data. - The
.envNightmare: Manually maintainingDATABASE_URL_DEV,DATABASE_URL_CHECKOUT, and editing.envon every branch change. - Cloud Branching (Neon, PlanetScale): Great developer experience, but proprietary, paid, and requires an internet connection. It doesn't work for offline development or standard local Docker setups.
The Solution: BranchBase
BranchBase pairs automated Git branch transitions with database cloning mechanisms and a transparent wire-protocol TCP proxy, keeping your connection strings stable while routing queries to branch-specific databases.
+---------------------------+
| Developer Machine |
+---------------------------+
|
`git checkout branch-b`
|
v
[ BranchBase Git Hook ]
|
+--------------------+--------------------+
| |
(Detects new branch) (Branch Provisioning)
| |
v v
+---------------------------------------+ +------------------------------------+
| BranchBase Proxy (Postgres / MySQL) | | Local Database |
+---------------------------------------+ +------------------------------------+
| - App connection string stays stable | | - `db_project_main` (frozen) |
| - Automatically routes queries to the | | - `db_project_branch_b` (active) |
| active Git branch database! | | (Created via engine driver) |
+---------------------------------------+ +------------------------------------+
Key Highlights
- Engine-Native Branching: Creates isolated branch databases using PostgreSQL
CREATE DATABASE ... TEMPLATE, MySQL schema/data replication, SQLite filesystem Copy-on-Write (clonefile/FICLONE), or MongoDB aggregation pipelines. - Transparent Wire Proxy: Your application connects to a stable local port (
5432for PostgreSQL or3306for MySQL). The proxy inspects the active Git branch from.git/HEADand routes connections to that branch's database without touching.env. - Automated Git Hook: Hooks into
post-checkoutandpost-mergevia lightweight POSIX scripts that run asynchronously. - Automatic Cleanup (
prune): When you delete or merge a Git branch,branchbase prunesafely tears down the associated ephemeral database. - 100% Local & Offline: No cloud telemetry, no subscription fees, and no internet connection required.
