dbnest 0.1.2

dbnest CLI – cozy local databases in seconds
# dbnest CLI

Cozy local databases in seconds.

## Quickstart

1. Create a database

SQLite:

```bash
dbnest up sqlite --path ./dev.sqlite
```

PostgreSQL:

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

List instances

```bash
dbnest ls
```

Check status:

```bash
dbnest status <INSTANCE_ID>
dbnest status --all
```

Lifecycle:

```bash
dbnest stop <INSTANCE_ID>
dbnest start <INSTANCE_ID>
dbnest restart <INSTANCE_ID>
dbnest rm <INSTANCE_ID> --force
dbnest rm <INSTANCE_ID> --force --volumes
```

2. Define schema
   Create a schema file or directory layout

###### schema.json:

```bash
{
  "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:

```bash
schema/
  users/
    columns.json
    indexes.json
```

with `columns.json` and `indexes.json` containing the respective table schema.

```bash
[
  { "name": "id", "type": "uuid", "primary_key": true },
  {
    "name": "email",
    "type": "string",
    "unique": true,
    "nullable": false
  },
  { "name": "created_at", "type": "timestamp", "default": "now" }
]
```

3. Generate SQL from schema (plan)

SQLite:

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

Postgres:

```bash
dbnest plan postgres --schema ./examples/schema.json    # from single json schema
dbnest plan postgres --schema ./schema/                 # from directory based schema
```

4. Apply schema to database (apply)

```bash
dbnest apply --id <INSTANCE_ID> --schema ./schema.json
# or
dbnest apply --id <INSTANCE_ID> --schema ./schema/
```

Provision and apply schema in one command:

```bash
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