Configuration¶
db-git init writes .db-git.toml at the repository root.
Example:
database_url = "postgresql://postgres:postgres@localhost:5432/myapp"
mode = "per-branch"
default_branch = "main"
strategy = "template"
on_active_connections = "terminate"
Supported configuration keys:
| Key | Description | Default |
|---|---|---|
database_url |
Database connection URL | required |
mode |
PostgreSQL/MySQL: either mode; SQLite: per-branch |
PostgreSQL: shared; SQLite/MySQL: per-branch |
default_branch |
Seed branch for per-branch mode | main |
strategy |
PostgreSQL: template or pgdump; SQLite: backup; MySQL: mysqldump |
required for PostgreSQL; SQLite/MySQL use engine defaults |
on_active_connections |
PostgreSQL: terminate or fail; SQLite/MySQL: fail |
PostgreSQL: terminate; SQLite/MySQL: fail |
snapshot_dir |
Shared-mode snapshot metadata/dump directory | db-git/snapshots under Git’s common directory |
max_snapshots |
Snapshot count kept by prune logic | 20 |
backup_timeout_ms |
SQLite backup deadline in milliseconds | 5000 |
force_terminate_timeout_ms |
PostgreSQL connection termination timeout | 5000 |
Configuration precedence for settings other than the seed URL:
- Built-in defaults
.db-git.toml- Environment variables
- CLI options
Environment variables:
DATABASE_URL
DB_GIT_DATABASE_URL
DB_GIT_MODE
DB_GIT_STRATEGY
DB_GIT_ON_ACTIVE_CONNECTIONS
DB_GIT_SNAPSHOT_DIR
DB_GIT_MAX_SNAPSHOTS
DB_GIT_BACKUP_TIMEOUT_MS
DB_GIT_FORCE_TERMINATE_TIMEOUT_MS
Seed URL precedence, highest first:
- Explicit
--database-url DB_GIT_DATABASE_URLdatabase_urlin.db-git.tomlDATABASE_URL, only when no seed is configured
Changed behavior: exporting an application DATABASE_URL no longer overrides
an initialized project's seed. To deliberately change the management connection,
use DB_GIT_DATABASE_URL or --database-url. Initialization still accepts
DATABASE_URL as a starting value when there is no saved seed; reinitialization
preserves the saved seed unless explicitly overridden.
See engine-specific URL details for PostgreSQL, MySQL, and SQLite.