Cozy local databases in seconds.
dbnest is a cross-platform CLI for provisioning local databases and initializing schema from a simple JSON (file or folder layout).
- SQLite embedded provisioning (no external dependencies)
- PostgreSQL server Docker instance (Docker required)
- Instance registry (list / remove with
--force) - Instance lifecycle status checks
- PostgreSQL lifecycle commands:
start,stop,restart - PostgreSQL persistent Docker volumes, removed only with
rm --force --volumes - Schema workflow:
plangenerates SQL from schemaapplyexecutes the schema against the databaseup --schemaprovisions and bootstraps in one command
- Schema input formats:
- Single JSON file (
schema.json) - Directory layout (
schema/<table>/columns.json, optionalindexes.json)
- Single JSON file (
0.1.2 hardening:
- Safer schema validation and deterministic plans
- Secret redaction in output by default
- Safer removal with
rm --force - PostgreSQL persistent Docker volumes
start/restart- Structured JSON errors when
--jsonis used - Additional registry, schema, output, and ignored Docker integration tests
Planned after SQLite/PostgreSQL hardening:
- MySQL via Docker
- Migration-aware planning through the existing
plancommand
cargo install dbnestcargo install --path crates/dbnest-cli- Create a database
SQLite:
dbnest up sqlite --path ./dev.sqlitePostgreSQL:
dbnest up postgres --user dev --password dev --db appdbList instances. This is metadata-fast and does not perform live health checks.
dbnest lsCheck instance status
dbnest status {instance_id}
dbnest status --all # status for all dbnest instancesStop a PostgreSQL instance:
dbnest stop {instance_id}
dbnest start {instance_id}
dbnest restart {instance_id}Remove an instance:
dbnest rm {instance_id} --force
dbnest rm {instance_id} --force --volumes # also remove PostgreSQL data volumes- Define schema Create a schema file or directory layout
{
"tables": [
{
"name": "users",
"columns": [
{ "name": "id", "type": "uuid", "primary_key": true },
{ "name": "email", "type": "string", "unique": true, "nullable": false },
{ "name": "created_at", "type": "timestamp", "default": "now" }
],
"indexes": [
{ "name": "idx_users_email", "columns": ["email"], "unique": true }
]
}
]
}Or a directory layout:
schema/
users/
columns.json
indexes.jsonwith columns.json and indexes.json containing the respective table schema.
[
{ "name": "id", "type": "uuid", "primary_key": true },
{
"name": "email",
"type": "string",
"unique": true,
"nullable": false
},
{ "name": "created_at", "type": "timestamp", "default": "now" }
]- Generate SQL from schema (plan)
SQLite:
dbnest plan sqlite --schema ./schema.json # from single json schema
dbnest plan sqlite --schema ./schema/ # from directory based schemaPostgres:
dbnest plan postgres --schema ./examples/schema.json # from single json schema
dbnest plan postgres --schema ./schema/ # from directory based schema- Apply schema to database (apply)
dbnest apply --id <INSTANCE_ID> --schema ./schema.json
# or
dbnest apply --id <INSTANCE_ID> --schema ./schema/Provision and apply schema in one command:
dbnest up sqlite --path ./dev.sqlite --schema ./schema.json
dbnest up sqlite --path ./dev.sqlite --schema ./schema.json --keep-on-failureCommands that print connection data redact secrets by default. Use --show-secrets only when you need the full connection URL.
docs/schema.mddescribes the JSON schema format.docs/lifecycle.mddescribes instance lifecycle behavior.docs/security.mddescribes secret redaction and local metadata handling.docs/development.mdanddocs/testing.mddescribe development workflows.
MIT