@cartanova/qgrid-cli 2.4.9 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ Use this reference for qgrid startup, configuration, and runtime-facing environm
4
4
 
5
5
  ## CLI options
6
6
 
7
- - `--db <url>`: PostgreSQL URL in `postgres://user:password@host:port/dbname` or `postgresql://...` form. Parsed by `packages/cli/src/cli.ts` and copied into `SONAMU_DB_*` env vars before server boot.
7
+ - `--db <url>`: PostgreSQL URL in `postgres://user:password@host:port/dbname` or `postgresql://...` form. Parsed by `packages/cli/src/cli.ts` as the highest-priority database input.
8
8
  - `-p, --port <port>`: server port. Default `44900`. The CLI validates the port and refuses to start if it is already in use.
9
9
  - `--skip-update`: skip qgrid CLI self-update check.
10
10
 
@@ -15,15 +15,31 @@ The CLI also ensures runtime CLIs are installed/current enough:
15
15
  - `codex` from `@openai/codex`, required for OpenAI tokens.
16
16
  - `claude` from `@anthropic-ai/claude-code`, required for Anthropic tokens.
17
17
 
18
+ ## CLI database env vars
19
+
20
+ `QGRID_DB_*` is the public database configuration for the packaged qgrid CLI.
21
+ Immediately before server boot, the CLI copies the resolved values into
22
+ Sonamu's internal `SONAMU_DB_*` variables. `--db` overrides `QGRID_DB_*`;
23
+ `QGRID_DB_*` overrides an existing `SONAMU_DB_*` value. The latter remains a
24
+ compatibility fallback and should not be the environment contract shown to CLI
25
+ users.
26
+
27
+ | Env | Default | Meaning |
28
+ |---|---:|---|
29
+ | `QGRID_DB_HOST` | `localhost` | PostgreSQL host. |
30
+ | `QGRID_DB_PORT` | `5432` | PostgreSQL port. |
31
+ | `QGRID_DB_USER` | `postgres` | PostgreSQL user. |
32
+ | `QGRID_DB_PASSWORD` | `postgres` | PostgreSQL password. |
33
+ | `QGRID_DB_NAME` | `qgrid` | PostgreSQL database. |
34
+
35
+ Source deployments that run `packages/api` without the packaged CLI must use
36
+ Sonamu's native `SONAMU_DB_HOST`, `SONAMU_DB_PORT`, `SONAMU_DB_USER`,
37
+ `SONAMU_DB_PASSWORD`, and `SONAMU_DB_NAME` variables directly.
38
+
18
39
  ## Server env vars agents should know
19
40
 
20
41
  | Env | Default | Meaning |
21
42
  |---|---:|---|
22
- | `SONAMU_DB_HOST` | `localhost` | PostgreSQL host. |
23
- | `SONAMU_DB_PORT` | `5432` | PostgreSQL port. |
24
- | `SONAMU_DB_USER` | `postgres` | PostgreSQL user. |
25
- | `SONAMU_DB_PASSWORD` | `postgres` | PostgreSQL password. |
26
- | `SONAMU_DB_NAME` | `qgrid` | PostgreSQL database. |
27
43
  | `NODE_ENV` | direct API: `development`; packaged CLI: `production` | Sonamu runtime profile. Use `staging` for remote non-production API deployments such as dev0. The profile does not create or rename the explicitly configured DB. |
28
44
  | `HOST` | `localhost` | Sonamu server listen host when running API directly. |
29
45
  | `PORT` | `44900` | Sonamu server listen port. In CLI mode this is derived from `--port`, not read as user input. |
@@ -64,7 +80,7 @@ When helping a user set up qgrid locally, check for `QGRID_PROJECT_NAME` or conf
64
80
 
65
81
  `packages/api/src/index.ts` runs `bootstrapServer` (`server-bootstrap.ts`) with a strict init → migrate → listen order:
66
82
 
67
- 1. `Sonamu.init()` loads Sonamu's native dotenv snapshot for the active `NODE_ENV` and reads the database connection from `SONAMU_DB_*`. Selecting `staging` alone does not create a staging DB; `SONAMU_DB_NAME` remains the explicit database name.
83
+ 1. The packaged CLI maps public `QGRID_DB_*` inputs to internal `SONAMU_DB_*`, then `Sonamu.init()` loads Sonamu's native dotenv snapshot for the active `NODE_ENV` and reads that internal database connection. Direct source API deployments set `SONAMU_DB_*` themselves. Selecting `staging` alone does not create a staging DB; the explicit database name remains authoritative.
68
84
  2. `runRequiredMigrations` (`startup-migrations.ts`) applies latest migrations from `packages/api/src/migrations` before the server listens. Migration failure exits the process — qgrid must not boot against a schema missing required columns such as `tokens.weight`. This is a hard-fail; it used to be a soft-fail warn inside `onStart`.
69
85
  3. `Sonamu.createServer()` starts the server. Its `onStart` in `packages/api/src/sonamu.config.ts`:
70
86
  1. Ensures PostgreSQL `tokens_changed` triggers.