dbnest 0.1.2

dbnest CLI – cozy local databases in seconds
dbnest-0.1.2 is not a library.

dbnest CLI

Cozy local databases in seconds.

Quickstart

  1. Create a database

SQLite:

dbnest up sqlite --path ./dev.sqlite

PostgreSQL:

dbnest up postgres --user dev --password dev --db appdb

List instances

dbnest ls

Check status:

dbnest status <INSTANCE_ID>
dbnest status --all

Lifecycle:

dbnest stop <INSTANCE_ID>
dbnest start <INSTANCE_ID>
dbnest restart <INSTANCE_ID>
dbnest rm <INSTANCE_ID> --force
dbnest rm <INSTANCE_ID> --force --volumes
  1. Define schema Create a schema file or directory layout
schema.json:
{
  "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.json

with 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" }
]
  1. Generate SQL from schema (plan)

SQLite:

dbnest plan sqlite --schema ./schema.json               # from single json schema
dbnest plan sqlite --schema ./schema/                   # from directory based schema

Postgres:

dbnest plan postgres --schema ./examples/schema.json    # from single json schema
dbnest plan postgres --schema ./schema/                 # from directory based schema
  1. 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-failure

Output And Secrets

Human and JSON output redact passwords by default. Commands that print instance data may support --show-secrets.

Development Docs

See the workspace docs/ directory for schema, lifecycle, security, testing, and implementation notes.


License

MIT