@carllee1983/dbcli 1.41.0 → 1.43.0

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbcli-agent",
3
- "version": "1.41.0",
3
+ "version": "1.43.0",
4
4
  "description": "Database CLI skill and command reference for AI agents.",
5
5
  "author": {
6
6
  "name": "Carl Lee",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbcli-agent",
3
- "version": "1.41.0",
3
+ "version": "1.43.0",
4
4
  "description": "Database CLI skill and command reference for AI agents",
5
5
  "author": {
6
6
  "name": "Carl Lee",
@@ -239,8 +239,10 @@ dbcli init --system elasticsearch \
239
239
  dbcli init --conn-name staging --env-file .env.staging --permission query-only
240
240
  dbcli init --conn-name prod --env-file .env.production --use-env-refs --skip-test
241
241
  dbcli use --list # show all, * marks default
242
- dbcli use prod # switch default
242
+ dbcli use prod # switch default (persists — avoid for one-off queries)
243
243
  dbcli query --use staging "SELECT 1" # one-shot override on any subcommand
244
+ DBCLI_CONNECTION=staging dbcli query "SELECT 1" # one-shot via env; parallel-safe
245
+ dbcli --use staging,prod query "SELECT count(*) FROM users" # read-only fan-out
244
246
  dbcli init --rename staging:stg # rename
245
247
  dbcli init --remove stg # remove
246
248
  ```
@@ -296,7 +298,7 @@ Full flags and edge cases: see [reference.md](reference.md) `init` section.
296
298
  | `use` | n/a | Show/switch default named connection (v2 only). |
297
299
  | `list` | query-only+ | Tables (SQL), collections (MongoDB), keys (Redis), or indices (Elasticsearch). |
298
300
  | `schema` | query-only+ | SQL: per-table or full scan into `.dbcli/schemas/`. MongoDB: sampled. ES: flattened mapping. Redis: per-key only (type/TTL/size). Supports `--recovery`. |
299
- | `query` | query-only+ | SQL, Mongo JSON (`--collection`), Redis command, or ES DSL/Lucene (`--collection`). `--format table\|json\|csv\|html`, `--ui` to open the interactive dashboard in a browser. Supports `--recovery`. |
301
+ | `query` | query-only+ | SQL, Mongo JSON (`--collection`), Redis command, or ES DSL/Lucene (`--collection`). `--format table\|json\|csv\|html`, `--ui` to open the interactive dashboard in a browser. `--fields` (projection), `--truncate` (cell width), `-f/--query-file` (read query from file or stdin), `--use a,b` (read-only fan-out). Supports `--recovery`. See **Query workflow flags**. |
300
302
  | `explain` | query-only+ | **(v1.23)** Read-only query plan with annotations. SQL only. Single query, `@saved-query`, `@file.sql`, or `--bulk @glob/*`. `--analyze` (EXPLAIN ANALYZE / MariaDB ANALYZE SELECT), `--format markdown\|json\|table`. |
301
303
  | `lint` | n/a | Static SQL anti-pattern advisor (no DB connection). 9 rules incl. schema-aware implicit-cast / NOT IN-nullable checks via the layered `.dbcli/schemas/` cache; global `--use <conn>` selects a named cache. Findings carry rewrite drafts + guarded `explain` verify commands (`--analyze` only for proven read-only SQL) — report-only, never executes. `--format text\|json\|markdown`, `--min-severity`, `--no-schema`, `--bulk`. Supports `--recovery`. |
302
304
  | `plan` | n/a | Static SQL risk analyzer (`--format text\|json`); classifies a statement without connecting to the database. |
@@ -304,10 +306,10 @@ Full flags and edge cases: see [reference.md](reference.md) `init` section.
304
306
  | `queries` | n/a | Manage saved snippets: `list` / `show` / `search` / `suggest` / `new` / `edit` / `check` / `delete` / `rename` / `copy` / `import` / `export`. |
305
307
  | `insert` / `update` | read-write+ | SQL or MongoDB only. JSON `--data` / `--set`; `--where` required on `update`; `--dry-run` first. Redis writes go through `query`. Supports `--recovery`. |
306
308
  | `delete` | data-admin+ | SQL or MongoDB; Redis has a basic implementation (see Redis section). `--where` required; `--dry-run` first. Supports `--recovery`. |
307
- | `export` | query-only+ | SQL, MongoDB, or **(v1.22)** Elasticsearch (DSL `--index` or whole-index scroll). Query → `--format json\|jsonl\|csv\|html` file or stdout. `html` emits a standalone interactive dashboard. Supports `--recovery`. |
309
+ | `export` | query-only+ | SQL, MongoDB, or **(v1.22)** Elasticsearch (DSL `--index` or whole-index scroll). Query → `--format json\|jsonl\|csv\|html` file or stdout. `html` emits a standalone interactive dashboard. **Fails closed rather than truncating silently**: if the auto-limit would drop rows, the export errors out and you must pass `--no-limit` or `--limit N`. Supports `--recovery`. |
308
310
  | `blacklist` | n/a | `list` / `table` / `column` subcommands redact sensitive data from query results. |
309
311
  | `check` | query-only+ | SQL only (best on MySQL/MariaDB). |
310
- | `diff` | query-only+ | SQL only. Save/compare schema snapshots. **(P1b)** `--against-orm <path>` compares a Prisma schema / DDL file / normalized JSON against the local schema cache (no DB connection): categorized drift (`missing_in_db` = error, `missing_in_orm` = warn, `mismatch` per tolerance table, `unmanaged`) with dry-run `migrate` proposals; exit 1 on error-level drift. `--orm-format prisma\|ddl\|json`, `--ignore <globs>`, `--format json\|table\|markdown`. |
312
+ | `diff` | query-only+ | SQL only. Save/compare schema snapshots. **(P1b)** `--against-orm <path>` compares a Prisma schema / DDL file / normalized JSON against the local schema cache (no DB connection): categorized drift (`missing_in_db` = error, `missing_in_orm` = warn, `mismatch` per tolerance table, `unmanaged`) with dry-run `migrate` proposals; exit 1 on error-level drift. `--orm-format prisma\|ddl\|json\|drizzle\|typeorm\|sequelize`, `--ignore <globs>`, `--format json\|table\|markdown`. Drizzle: point at `drizzle/meta/<NNNN>_snapshot.json` (run `drizzle-kit generate` first; `.ts` sources are rejected with a hint). TypeORM/Sequelize: feed tool-generated DDL (`schema:log` / a schema-only dump); source files are rejected with the exact generation command to run. |
311
313
  | `snapshot` | query-only+ | **(v1.25)** SQL only. Capture a result fingerprint (`rowCount` + per-column null/distinct/min/max/sum + order-independent checksum). `--out` (default `.dbcli/snapshots/snap-<ts>.json`), `--rows`, `--stdout`, `--format`, `--no-limit`. Baseline for `assert --against`. |
312
314
  | `assert` | query-only+ | **(v1.25)** SQL only. Verify an invariant; exit 1 on failure unless `--no-fail`. `--expect "rows>0\|value==X\|col:c not null\|unique\|between a and b\|>= n"`, `--vs <query> --compare rows\|value` (reconcile), `--against <snapshot> --tolerance <pct>`. |
313
315
  | `verification` | n/a | Inspect and manage local verification artifacts. `list` / `show <id-or-path>` / `summary` are read-only; `prune` is dry-run by default and deletes only with `--execute --force`. Reads `<cwd>/.dbcli/verification/`; no DB connection, no audit writes. |
@@ -325,8 +327,9 @@ Full flags and edge cases: see [reference.md](reference.md) `init` section.
325
327
  | `skill` | n/a | Generate / install AI skill docs (`--install <claude\|gemini\|antigravity\|copilot\|cursor\|codex\|windsurf>`); `skill tasks list/show/plan` for Agent Task Packs; `skill context` for an LLM prompt-context payload (for injecting into another LLM, not needed for normal operation). |
326
328
  | `migrate` | admin | SQL only. **DDL; dry-run by default** — needs `--execute`. |
327
329
 
328
- `--use <name>` on any subcommand (including `status` / `doctor`) targets a v2 connection
329
- without changing the default. `--recovery` is honoured by `query`, `q`, `insert`, `update`,
330
+ Use root-level `dbcli --use <name> <command>` for any command; `query`, `schema`, `list`,
331
+ `export`, and `check` also accept command-level `--use`. Both target a v2 connection without
332
+ changing the default. `--recovery` is honoured by `query`, `q`, `insert`, `update`,
330
333
  `delete`, `export`, `schema`, `inspect`, `lint`, and `diff --against-orm` (see **On failure** above).
331
334
 
332
335
  **Write & query flag semantics** (SQL/Mongo `insert`/`update`):
@@ -344,6 +347,27 @@ without changing the default. `--recovery` is honoured by `query`, `q`, `insert`
344
347
  - `--recovery` is recommended for automated agent pipelines (enables `dbcli recover --apply`
345
348
  after a failure); optional for one-off manual writes.
346
349
 
350
+ ## Query workflow flags
351
+
352
+ These exist so you do not have to pipe output through `head` / `jq` / `python3`
353
+ to make it usable. Reach for them instead of post-processing.
354
+
355
+ | Need | Flag | Notes |
356
+ |------|------|-------|
357
+ | Only some columns | `--fields sn,bet,created_at` | SQL and MongoDB. Mongo pushes a real `projection` / `$project` to the driver; `_id` is dropped unless you ask for it. A field the result lacks comes back as `null`, so verify spellings with `schema` before reading meaning into an all-null column. |
358
+ | Everything except a huge column | `--fields=-raw_response` | Exclusion form. Include and exclude cannot be mixed. |
359
+ | One field is a giant JSON blob | `--truncate 120` | Table output truncates cells at 120 chars **by default** and marks them `…(+3412 chars)`. `--no-truncate` disables it. Explicit truncation flags are rejected on JSON, CSV, HTML, and `--ui` output. |
360
+ | Query has quotes / newlines / `$regex` | `-f pipeline.json` or `-f -` | Reads the query from a file or stdin; use a heredoc for Mongo pipelines. Passing both a file and positional query text is an error, never a silent pick. `-f -` needs piped input — it refuses an interactive terminal rather than hanging. |
361
+ | Same query across connections | `--use hub-prod,site-a` | Read-only fan-out. Per-connection results, one failure does not cancel the others. Exit `0` all-ok, `2` mixed, `1` all-failed. Rejects writes, `--recovery`, `--ui`, CSV/HTML. |
362
+ | Pick a connection for one call | `DBCLI_CONNECTION=hub-prod dbcli query …` | Env var, or `--use` on the subcommand. Priority: `--use` > `DBCLI_CONNECTION` > saved default. Neither writes the default back to disk, so parallel shells never fight. Requires a v2 config — a single-connection (v1) project rejects both rather than silently running its only connection. **Do not** use `dbcli use <name>` just to switch for one query. |
363
+
364
+ **Truncation is reported, never implied.** When the query-only auto-limit trims a
365
+ result, the table footer reads `Rows: 1000 (truncated; limit 1000)`, `--format json`
366
+ carries `metadata.truncated` / `metadata.limit_applied`, and CSV appends a `#`
367
+ comment. `Rows: 1000` with no marker means exactly 1000 rows exist — do not infer
368
+ truncation from a round number. This applies to `query` and to `q` snippets
369
+ (whose own 1000-row guard reports the same way). `export` refuses to truncate at all. Redis replies trimmed by the size guard report the same way, and each size-guard warning is printed on stderr.
370
+
347
371
  ## Permission levels
348
372
 
349
373
  | Level | Allowed |
@@ -112,7 +112,7 @@ dbcli schema --use prod # Scan prod DB; saves to .dbcli/schemas/prod
112
112
 
113
113
  ### query
114
114
 
115
- Execute SQL query (MySQL/PostgreSQL/MariaDB) or JSON filter/pipeline (MongoDB).
115
+ Execute a SQL statement, MongoDB filter/pipeline, allow-listed Redis command, or Elasticsearch DSL/Lucene query.
116
116
 
117
117
  ```bash
118
118
  # SQL databases
@@ -143,13 +143,84 @@ dbcli query "SELECT day, dau FROM dau_daily" --ui # open in brows
143
143
  dbcli query "SELECT * FROM orders" --format html > orders.html # pipe to stdout
144
144
  ```
145
145
 
146
- **Options:** `--format <table|json|csv|html>`, `--ui` (open the dashboard in the system browser; implies `--format html`), `--limit <number>`, `--no-limit`, `--collection <name>` (MongoDB / Elasticsearch), `--index <name>` (Elasticsearch alias for `--collection`), `--recovery`
146
+ **Options:** `--format <table|json|csv|html>`, `--ui` (open the dashboard in the system browser; implies `--format html`), `--limit <number>`, `--no-limit`, `--collection <name>` (MongoDB / Elasticsearch), `--index <name>` (Elasticsearch alias for `--collection`), `--fields <list>`, `--truncate <number>` / `--no-truncate`, `-f, --query-file <path>`, `--use <name[,name]>`, `--recovery`
147
147
  **Permission:** query-only+ (Redis: per-command; Elasticsearch: per HTTP method/path)
148
148
 
149
+ #### Field projection (`--fields`)
150
+
151
+ ```bash
152
+ dbcli query "SELECT * FROM bet_log" --fields sn,currency,bet
153
+ dbcli query "SELECT * FROM bet_log" --fields=-raw_response,-created_at # exclusion
154
+ dbcli query '{"station_code":"cmg9998"}' --collection raw_bet_log --fields sn,bet
155
+ ```
156
+
157
+ Include and exclude forms cannot be mixed. Dotted paths (`user.email`) are supported.
158
+ On MongoDB the selection becomes a driver-level `projection` (find) or a trailing
159
+ `$project` stage (aggregate), so the omitted fields never leave the server; `_id` is
160
+ excluded unless listed explicitly. On SQL the rows are projected after fetch — write
161
+ an explicit column list in the `SELECT` when you also want to cut transfer cost.
162
+ Blacklisted columns stay blacklisted: naming one in `--fields` yields no value and the
163
+ result still carries the blacklist `securityNotification`. A requested field that does
164
+ not exist in the result comes back as `null`.
165
+
166
+ #### Cell truncation (`--truncate`)
167
+
168
+ ```bash
169
+ dbcli query "SELECT sn, raw_response FROM bet_log" # table: 120-char default
170
+ dbcli query "SELECT sn, raw_response FROM bet_log" --truncate 40
171
+ dbcli query "SELECT sn, raw_response FROM bet_log" --no-truncate
172
+ ```
173
+
174
+ Table output truncates each serialized cell at 120 Unicode code points by default and
175
+ appends `…(+N chars)`; counting by code point keeps multi-byte characters and emoji
176
+ intact. `--truncate <n>` sets the width, `--no-truncate` disables it. Explicit truncation
177
+ flags are rejected with JSON, CSV, HTML, and `--ui` output.
178
+
179
+ #### Query from a file or stdin (`-f`)
180
+
181
+ ```bash
182
+ dbcli query -f report.sql
183
+ dbcli query --collection raw_bet_log -f - <<'EOF'
184
+ [{"$match": {"sn": {"$regex": "^SN0000"}}}, {"$group": {"_id": "$currency", "n": {"$sum": 1}}}]
185
+ EOF
186
+ ```
187
+
188
+ Avoids shell quoting entirely — the usual reason a Mongo pipeline containing `$regex`
189
+ or nested date objects fails. Supplying both `--query-file` and positional query text
190
+ is an error rather than a silent choice, and an empty file or empty stdin is refused.
191
+ `-f -` requires piped input: on an interactive terminal dbcli refuses immediately
192
+ instead of waiting silently for input that is never coming.
193
+
194
+ #### One-shot connection selection and read-only fan-out
195
+
196
+ Selection precedence is explicit `--use`, then `DBCLI_CONNECTION`, then the saved default.
197
+ `query`, `schema`, `list`, `export`, and `check` accept command-level `--use`; for other
198
+ commands use root-level `dbcli --use <name> <command>`. One-shot selectors never update the
199
+ saved default and require a v2 config. A legacy v1 single-connection config rejects them
200
+ instead of silently running its only connection.
201
+
202
+ An explicit comma-separated `--use primary,staging` fans one query out to several named
203
+ connections. `DBCLI_CONNECTION` always names one literal connection and never enables
204
+ fan-out. SQL permits `SELECT`, `SHOW`, `DESCRIBE`, and `EXPLAIN`; MongoDB permits filters and
205
+ read-only pipelines without top-level `$out` / `$merge`; Elasticsearch permits searches.
206
+ Redis, writes, `--recovery`, `--ui`, CSV, and HTML are rejected before execution. Each
207
+ connection keeps its own blacklist, limit metadata, audit entry, and error. Aggregate exit
208
+ codes are `0` when all succeed, `2` for mixed outcomes, and `1` when all fail or preflight
209
+ rejects the request.
210
+
211
+ #### Truncation is stated, not implied
212
+
213
+ When the query-only auto-limit trims the result, the table footer reads
214
+ `Rows: 1000 (truncated; limit 1000)`, `--format json` carries
215
+ `metadata.truncated` and `metadata.limit_applied`, and CSV appends a `#` comment line.
216
+ dbcli fetches one row past the cap to decide this, so a result of exactly 1000 rows is
217
+ reported as `truncated: false` — never infer truncation from a round row count.
218
+
149
219
  > **MongoDB notes:**
150
220
  > - SQL syntax is rejected — use JSON object (filter) or JSON array (pipeline)
151
221
  > - `--collection <name>` is required
152
- > - Auto-limit does not apply; use `$limit` in your pipeline if needed
222
+ > - Query-only auto-limit applies to filters and to pipelines without their own
223
+ > `$limit`; the applied cap and truncation are reported in the result metadata
153
224
 
154
225
  > **Redis notes:**
155
226
  > - The first token must be an allow-listed command (`GET`/`SET`/`HGET`/`HSET`/`DEL`/...). Unknown commands are refused.
@@ -661,9 +732,13 @@ dbcli export orders --no-limit --format jsonl # scroll the whole ind
661
732
  **Options:** `--format <json|jsonl|csv|html>` (required), `--output <path>`, `--force`, `--recovery`, `--collection <name>` (MongoDB collection) / `--index <name>` (Elasticsearch index; alias for `--collection`), `--limit <number>` (overrides auto-limit), `--no-limit` (Elasticsearch full-index scroll)
662
733
  **Permission:** query-only+ — SQL, MongoDB, and **(v1.22)** Elasticsearch.
663
734
 
735
+ If the query-only auto-limit would omit rows, export fails closed with exit code `1` and
736
+ writes no partial file. Re-run with `--no-limit` to export everything, or `--limit N` to
737
+ accept a bounded export explicitly. This applies to SQL, MongoDB, and Elasticsearch.
738
+
664
739
  The `html` format emits the same self-contained dashboard as `query --ui` (see [Interactive HTML dashboard](#interactive-html-dashboard)). Because `export` runs raw SQL (no snippet metadata), the HTML report is always rendered as a sortable / filterable table — no KPIs or charts. Use `dbcli q @<name> --format html` (or `--ui`) for the charted view.
665
740
 
666
- > **Elasticsearch export (v1.22):** pass a search DSL with `--index <index>` to export the hits, or pass an index name as the query to scroll the whole index via `match_all`. Default cap is 1000 rows; `--no-limit` streams the full index via scroll in batches. Index-level blacklist is checked before export and an audit record is written.
741
+ > **Elasticsearch export (v1.22):** pass a search DSL with `--index <index>` to export the hits, or pass an index name as the query to scroll the whole index via `match_all`. Default cap is 1000 rows; reaching it fails closed unless the caller explicitly uses `--limit N`, while `--no-limit` streams the full index via scroll in batches. Index-level blacklist is checked before export and an audit record is written.
667
742
 
668
743
  ### blacklist
669
744
 
@@ -722,6 +797,10 @@ separate `--snapshot` / `--against` workflow.
722
797
  dbcli diff --against-orm prisma/schema.prisma --format json
723
798
  dbcli diff --against-orm schema.normalized.json --orm-format json --format table
724
799
 
800
+ # Drizzle requires a PostgreSQL drizzle-kit v7 snapshot (generate it first)
801
+ drizzle-kit generate
802
+ dbcli diff --against-orm drizzle/meta/0001_snapshot.json --orm-format drizzle --format table
803
+
725
804
  # DDL accepts repeatable or comma-separated paths and real filesystem globs
726
805
  dbcli diff --against-orm "migrations/*.sql" --format markdown
727
806
  dbcli diff --against-orm migrations/base.sql,migrations/accounts.sql \
@@ -731,11 +810,60 @@ dbcli diff --against-orm migrations/base.sql,migrations/accounts.sql \
731
810
  dbcli diff --against-orm prisma/schema.prisma --ignore 'public.audit_*,public.Legacy'
732
811
  ```
733
812
 
813
+ ##### TypeORM
814
+
815
+ TypeORM entities are not parsed directly. `schema:log` prints the SQL that
816
+ `schema:sync` would execute without applying it; `-d` is the required data-source
817
+ path. Generate that DDL, then select the `typeorm` alias so the report is tagged
818
+ `ormSource: typeorm`:
819
+
820
+ ```bash
821
+ bunx typeorm schema:log -d <path/to/datasource> > schema.sql
822
+ dbcli diff --against-orm schema.sql --orm-format typeorm --format table
823
+ ```
824
+
825
+ With `--orm-format typeorm`, `typeorm_metadata` and `migrations` are
826
+ default-ignored and appear as `unmanaged` rather than scored drift. Passing a
827
+ TypeORM `.ts`, `.js`, `.mjs`, or `.cjs` source file is rejected with the
828
+ `schema:log` command to run. See the
829
+ [TypeORM CLI documentation](https://typeorm.io/docs/using-cli) and
830
+ [`SchemaLogCommand`](https://github.com/typeorm/typeorm/blob/master/src/commands/SchemaLogCommand.ts).
831
+
832
+ ##### Sequelize
833
+
834
+ Sequelize CLI does not provide a universal `db:migrate --dry-run`. Point the
835
+ project's existing Sequelize configuration at an empty scratch database, apply
836
+ the migrations there, and dump definitions without row data:
837
+
838
+ ```bash
839
+ # Configure Sequelize for an empty scratch database first
840
+ bunx sequelize-cli db:migrate
841
+
842
+ # PostgreSQL scratch database
843
+ pg_dump --schema-only <scratch-database> > schema.sql
844
+
845
+ # MySQL scratch database
846
+ mysqldump --no-data <database> > schema.sql
847
+
848
+ dbcli diff --against-orm schema.sql --orm-format sequelize --format json
849
+ ```
850
+
851
+ With `--orm-format sequelize`, `SequelizeMeta` is default-ignored and appears as
852
+ `unmanaged` rather than scored drift. Passing a Sequelize `.ts`, `.js`, `.mjs`,
853
+ or `.cjs` model file is rejected with the scratch-database and schema-only dump
854
+ recipe. See the
855
+ [Sequelize CLI migration command](https://github.com/sequelize/cli/blob/main/src/commands/migrate.js),
856
+ [PostgreSQL `pg_dump`](https://www.postgresql.org/docs/current/app-pgdump.html),
857
+ and [MySQL `mysqldump`](https://dev.mysql.com/doc/refman/8.4/en/mysqldump-definition-data-dumps.html)
858
+ references.
859
+
734
860
  | Option | Behavior |
735
861
  | :--- | :--- |
736
- | `--against-orm <paths>` | Repeatable or comma-separated input. DDL inputs support real filesystem globs; matches are deduplicated and put in deterministic path order, then parsed as one shared ordered context so an index in a later file can attach to a table declared in an earlier file. Prisma and normalized JSON accept exactly one file, and globs are rejected for those formats. |
737
- | `--orm-format prisma\|ddl\|json` | Override extension/content detection. Without it, dbcli detects Prisma, DDL, or normalized JSON from the path and content. |
738
- | `--ignore <globs>` | Comma-separated, case-sensitive table globs. Patterns match the qualified display identity (for example `public.Users`). `_prisma_migrations` is always unmanaged. |
862
+ | `--against-orm <paths>` | Repeatable or comma-separated input. DDL-family inputs (raw DDL, TypeORM, and Sequelize) support real filesystem globs; matches are deduplicated and put in deterministic path order, then parsed as one shared ordered context so an index in a later file can attach to a table declared in an earlier file. Prisma, normalized JSON, and Drizzle accept exactly one file, and globs are rejected for those formats. |
863
+ | Drizzle input | Run `drizzle-kit generate`, then pass the PostgreSQL drizzle-kit v7 snapshot at `drizzle/meta/<NNNN>_snapshot.json`. TypeScript ORM schema sources (`.ts` or `.TS`) are rejected with that snapshot-generation hint; dbcli does not parse them directly. |
864
+ | TypeORM / Sequelize input | Generate DDL with the ORM/database tooling, then pass the SQL file with the matching `typeorm` or `sequelize` alias. Entity/model source files are rejected rather than parsed. |
865
+ | `--orm-format prisma\|ddl\|json\|drizzle\|typeorm\|sequelize` | Override extension/content detection. The `typeorm` and `sequelize` aliases use the DDL adapter while preserving the source tag and ORM-specific default ignores. Without an override, dbcli detects Prisma, raw DDL, normalized JSON, or a Drizzle snapshot from the path and content. |
866
+ | `--ignore <globs>` | Comma-separated, case-sensitive table globs. Patterns match the qualified display identity (for example `public.Users`). `_prisma_migrations` is always unmanaged; the TypeORM alias additionally ignores `typeorm_metadata` and `migrations`, and the Sequelize alias additionally ignores `SequelizeMeta`. |
739
867
  | `--format json\|table\|markdown` | Select machine JSON, human table, or Markdown output. Markdown is available only in ORM drift mode. |
740
868
  | `--recovery` | On an I/O, configuration, empty-cache, invalid-format, or unsupported-engine failure, emit and save a structured recovery envelope. Invalid Prisma/DDL constructs normally become `unparsed` entries instead of throwing. |
741
869
 
@@ -783,9 +911,11 @@ another.
783
911
  columns, multi-schema datasource configuration, malformed declarations, unknown
784
912
  attributes, and unsupported native mappings are never guessed.
785
913
 
786
- Prisma and DDL constructs outside the supported subset are retained in
914
+ Prisma, DDL, and Drizzle constructs outside the supported subset are retained in
787
915
  `unparsed` with a `blocked:` reason. These entries are separate from scored drift:
788
916
  inspect and resolve them before treating an otherwise clean summary as complete.
917
+ Drizzle enums and other unsupported snapshot constructs therefore appear as blocked
918
+ `unparsed` entries rather than managed tables or columns.
789
919
  Multi-file DDL is consumed as one deterministic shared ordered statement context,
790
920
  so later `CREATE INDEX` statements can reference tables declared in earlier
791
921
  files. PostgreSQL `PARTITION BY` and MySQL/MariaDB table engine, charset, and
@@ -2,7 +2,7 @@
2
2
  "name": "dbcli-agent",
3
3
  "displayName": "dbcli Agent",
4
4
  "description": "Database CLI skill and command reference for AI agents.",
5
- "version": "1.41.0",
5
+ "version": "1.43.0",
6
6
  "author": {
7
7
  "name": "Carl Lee",
8
8
  "url": "https://github.com/CarlLee1983"
@@ -239,8 +239,10 @@ dbcli init --system elasticsearch \
239
239
  dbcli init --conn-name staging --env-file .env.staging --permission query-only
240
240
  dbcli init --conn-name prod --env-file .env.production --use-env-refs --skip-test
241
241
  dbcli use --list # show all, * marks default
242
- dbcli use prod # switch default
242
+ dbcli use prod # switch default (persists — avoid for one-off queries)
243
243
  dbcli query --use staging "SELECT 1" # one-shot override on any subcommand
244
+ DBCLI_CONNECTION=staging dbcli query "SELECT 1" # one-shot via env; parallel-safe
245
+ dbcli --use staging,prod query "SELECT count(*) FROM users" # read-only fan-out
244
246
  dbcli init --rename staging:stg # rename
245
247
  dbcli init --remove stg # remove
246
248
  ```
@@ -296,7 +298,7 @@ Full flags and edge cases: see [reference.md](reference.md) `init` section.
296
298
  | `use` | n/a | Show/switch default named connection (v2 only). |
297
299
  | `list` | query-only+ | Tables (SQL), collections (MongoDB), keys (Redis), or indices (Elasticsearch). |
298
300
  | `schema` | query-only+ | SQL: per-table or full scan into `.dbcli/schemas/`. MongoDB: sampled. ES: flattened mapping. Redis: per-key only (type/TTL/size). Supports `--recovery`. |
299
- | `query` | query-only+ | SQL, Mongo JSON (`--collection`), Redis command, or ES DSL/Lucene (`--collection`). `--format table\|json\|csv\|html`, `--ui` to open the interactive dashboard in a browser. Supports `--recovery`. |
301
+ | `query` | query-only+ | SQL, Mongo JSON (`--collection`), Redis command, or ES DSL/Lucene (`--collection`). `--format table\|json\|csv\|html`, `--ui` to open the interactive dashboard in a browser. `--fields` (projection), `--truncate` (cell width), `-f/--query-file` (read query from file or stdin), `--use a,b` (read-only fan-out). Supports `--recovery`. See **Query workflow flags**. |
300
302
  | `explain` | query-only+ | **(v1.23)** Read-only query plan with annotations. SQL only. Single query, `@saved-query`, `@file.sql`, or `--bulk @glob/*`. `--analyze` (EXPLAIN ANALYZE / MariaDB ANALYZE SELECT), `--format markdown\|json\|table`. |
301
303
  | `lint` | n/a | Static SQL anti-pattern advisor (no DB connection). 9 rules incl. schema-aware implicit-cast / NOT IN-nullable checks via the layered `.dbcli/schemas/` cache; global `--use <conn>` selects a named cache. Findings carry rewrite drafts + guarded `explain` verify commands (`--analyze` only for proven read-only SQL) — report-only, never executes. `--format text\|json\|markdown`, `--min-severity`, `--no-schema`, `--bulk`. Supports `--recovery`. |
302
304
  | `plan` | n/a | Static SQL risk analyzer (`--format text\|json`); classifies a statement without connecting to the database. |
@@ -304,10 +306,10 @@ Full flags and edge cases: see [reference.md](reference.md) `init` section.
304
306
  | `queries` | n/a | Manage saved snippets: `list` / `show` / `search` / `suggest` / `new` / `edit` / `check` / `delete` / `rename` / `copy` / `import` / `export`. |
305
307
  | `insert` / `update` | read-write+ | SQL or MongoDB only. JSON `--data` / `--set`; `--where` required on `update`; `--dry-run` first. Redis writes go through `query`. Supports `--recovery`. |
306
308
  | `delete` | data-admin+ | SQL or MongoDB; Redis has a basic implementation (see Redis section). `--where` required; `--dry-run` first. Supports `--recovery`. |
307
- | `export` | query-only+ | SQL, MongoDB, or **(v1.22)** Elasticsearch (DSL `--index` or whole-index scroll). Query → `--format json\|jsonl\|csv\|html` file or stdout. `html` emits a standalone interactive dashboard. Supports `--recovery`. |
309
+ | `export` | query-only+ | SQL, MongoDB, or **(v1.22)** Elasticsearch (DSL `--index` or whole-index scroll). Query → `--format json\|jsonl\|csv\|html` file or stdout. `html` emits a standalone interactive dashboard. **Fails closed rather than truncating silently**: if the auto-limit would drop rows, the export errors out and you must pass `--no-limit` or `--limit N`. Supports `--recovery`. |
308
310
  | `blacklist` | n/a | `list` / `table` / `column` subcommands redact sensitive data from query results. |
309
311
  | `check` | query-only+ | SQL only (best on MySQL/MariaDB). |
310
- | `diff` | query-only+ | SQL only. Save/compare schema snapshots. **(P1b)** `--against-orm <path>` compares a Prisma schema / DDL file / normalized JSON against the local schema cache (no DB connection): categorized drift (`missing_in_db` = error, `missing_in_orm` = warn, `mismatch` per tolerance table, `unmanaged`) with dry-run `migrate` proposals; exit 1 on error-level drift. `--orm-format prisma\|ddl\|json`, `--ignore <globs>`, `--format json\|table\|markdown`. |
312
+ | `diff` | query-only+ | SQL only. Save/compare schema snapshots. **(P1b)** `--against-orm <path>` compares a Prisma schema / DDL file / normalized JSON against the local schema cache (no DB connection): categorized drift (`missing_in_db` = error, `missing_in_orm` = warn, `mismatch` per tolerance table, `unmanaged`) with dry-run `migrate` proposals; exit 1 on error-level drift. `--orm-format prisma\|ddl\|json\|drizzle\|typeorm\|sequelize`, `--ignore <globs>`, `--format json\|table\|markdown`. Drizzle: point at `drizzle/meta/<NNNN>_snapshot.json` (run `drizzle-kit generate` first; `.ts` sources are rejected with a hint). TypeORM/Sequelize: feed tool-generated DDL (`schema:log` / a schema-only dump); source files are rejected with the exact generation command to run. |
311
313
  | `snapshot` | query-only+ | **(v1.25)** SQL only. Capture a result fingerprint (`rowCount` + per-column null/distinct/min/max/sum + order-independent checksum). `--out` (default `.dbcli/snapshots/snap-<ts>.json`), `--rows`, `--stdout`, `--format`, `--no-limit`. Baseline for `assert --against`. |
312
314
  | `assert` | query-only+ | **(v1.25)** SQL only. Verify an invariant; exit 1 on failure unless `--no-fail`. `--expect "rows>0\|value==X\|col:c not null\|unique\|between a and b\|>= n"`, `--vs <query> --compare rows\|value` (reconcile), `--against <snapshot> --tolerance <pct>`. |
313
315
  | `verification` | n/a | Inspect and manage local verification artifacts. `list` / `show <id-or-path>` / `summary` are read-only; `prune` is dry-run by default and deletes only with `--execute --force`. Reads `<cwd>/.dbcli/verification/`; no DB connection, no audit writes. |
@@ -325,8 +327,9 @@ Full flags and edge cases: see [reference.md](reference.md) `init` section.
325
327
  | `skill` | n/a | Generate / install AI skill docs (`--install <claude\|gemini\|antigravity\|copilot\|cursor\|codex\|windsurf>`); `skill tasks list/show/plan` for Agent Task Packs; `skill context` for an LLM prompt-context payload (for injecting into another LLM, not needed for normal operation). |
326
328
  | `migrate` | admin | SQL only. **DDL; dry-run by default** — needs `--execute`. |
327
329
 
328
- `--use <name>` on any subcommand (including `status` / `doctor`) targets a v2 connection
329
- without changing the default. `--recovery` is honoured by `query`, `q`, `insert`, `update`,
330
+ Use root-level `dbcli --use <name> <command>` for any command; `query`, `schema`, `list`,
331
+ `export`, and `check` also accept command-level `--use`. Both target a v2 connection without
332
+ changing the default. `--recovery` is honoured by `query`, `q`, `insert`, `update`,
330
333
  `delete`, `export`, `schema`, `inspect`, `lint`, and `diff --against-orm` (see **On failure** above).
331
334
 
332
335
  **Write & query flag semantics** (SQL/Mongo `insert`/`update`):
@@ -344,6 +347,27 @@ without changing the default. `--recovery` is honoured by `query`, `q`, `insert`
344
347
  - `--recovery` is recommended for automated agent pipelines (enables `dbcli recover --apply`
345
348
  after a failure); optional for one-off manual writes.
346
349
 
350
+ ## Query workflow flags
351
+
352
+ These exist so you do not have to pipe output through `head` / `jq` / `python3`
353
+ to make it usable. Reach for them instead of post-processing.
354
+
355
+ | Need | Flag | Notes |
356
+ |------|------|-------|
357
+ | Only some columns | `--fields sn,bet,created_at` | SQL and MongoDB. Mongo pushes a real `projection` / `$project` to the driver; `_id` is dropped unless you ask for it. A field the result lacks comes back as `null`, so verify spellings with `schema` before reading meaning into an all-null column. |
358
+ | Everything except a huge column | `--fields=-raw_response` | Exclusion form. Include and exclude cannot be mixed. |
359
+ | One field is a giant JSON blob | `--truncate 120` | Table output truncates cells at 120 chars **by default** and marks them `…(+3412 chars)`. `--no-truncate` disables it. Explicit truncation flags are rejected on JSON, CSV, HTML, and `--ui` output. |
360
+ | Query has quotes / newlines / `$regex` | `-f pipeline.json` or `-f -` | Reads the query from a file or stdin; use a heredoc for Mongo pipelines. Passing both a file and positional query text is an error, never a silent pick. `-f -` needs piped input — it refuses an interactive terminal rather than hanging. |
361
+ | Same query across connections | `--use hub-prod,site-a` | Read-only fan-out. Per-connection results, one failure does not cancel the others. Exit `0` all-ok, `2` mixed, `1` all-failed. Rejects writes, `--recovery`, `--ui`, CSV/HTML. |
362
+ | Pick a connection for one call | `DBCLI_CONNECTION=hub-prod dbcli query …` | Env var, or `--use` on the subcommand. Priority: `--use` > `DBCLI_CONNECTION` > saved default. Neither writes the default back to disk, so parallel shells never fight. Requires a v2 config — a single-connection (v1) project rejects both rather than silently running its only connection. **Do not** use `dbcli use <name>` just to switch for one query. |
363
+
364
+ **Truncation is reported, never implied.** When the query-only auto-limit trims a
365
+ result, the table footer reads `Rows: 1000 (truncated; limit 1000)`, `--format json`
366
+ carries `metadata.truncated` / `metadata.limit_applied`, and CSV appends a `#`
367
+ comment. `Rows: 1000` with no marker means exactly 1000 rows exist — do not infer
368
+ truncation from a round number. This applies to `query` and to `q` snippets
369
+ (whose own 1000-row guard reports the same way). `export` refuses to truncate at all. Redis replies trimmed by the size guard report the same way, and each size-guard warning is printed on stderr.
370
+
347
371
  ## Permission levels
348
372
 
349
373
  | Level | Allowed |
@@ -112,7 +112,7 @@ dbcli schema --use prod # Scan prod DB; saves to .dbcli/schemas/prod
112
112
 
113
113
  ### query
114
114
 
115
- Execute SQL query (MySQL/PostgreSQL/MariaDB) or JSON filter/pipeline (MongoDB).
115
+ Execute a SQL statement, MongoDB filter/pipeline, allow-listed Redis command, or Elasticsearch DSL/Lucene query.
116
116
 
117
117
  ```bash
118
118
  # SQL databases
@@ -143,13 +143,84 @@ dbcli query "SELECT day, dau FROM dau_daily" --ui # open in brows
143
143
  dbcli query "SELECT * FROM orders" --format html > orders.html # pipe to stdout
144
144
  ```
145
145
 
146
- **Options:** `--format <table|json|csv|html>`, `--ui` (open the dashboard in the system browser; implies `--format html`), `--limit <number>`, `--no-limit`, `--collection <name>` (MongoDB / Elasticsearch), `--index <name>` (Elasticsearch alias for `--collection`), `--recovery`
146
+ **Options:** `--format <table|json|csv|html>`, `--ui` (open the dashboard in the system browser; implies `--format html`), `--limit <number>`, `--no-limit`, `--collection <name>` (MongoDB / Elasticsearch), `--index <name>` (Elasticsearch alias for `--collection`), `--fields <list>`, `--truncate <number>` / `--no-truncate`, `-f, --query-file <path>`, `--use <name[,name]>`, `--recovery`
147
147
  **Permission:** query-only+ (Redis: per-command; Elasticsearch: per HTTP method/path)
148
148
 
149
+ #### Field projection (`--fields`)
150
+
151
+ ```bash
152
+ dbcli query "SELECT * FROM bet_log" --fields sn,currency,bet
153
+ dbcli query "SELECT * FROM bet_log" --fields=-raw_response,-created_at # exclusion
154
+ dbcli query '{"station_code":"cmg9998"}' --collection raw_bet_log --fields sn,bet
155
+ ```
156
+
157
+ Include and exclude forms cannot be mixed. Dotted paths (`user.email`) are supported.
158
+ On MongoDB the selection becomes a driver-level `projection` (find) or a trailing
159
+ `$project` stage (aggregate), so the omitted fields never leave the server; `_id` is
160
+ excluded unless listed explicitly. On SQL the rows are projected after fetch — write
161
+ an explicit column list in the `SELECT` when you also want to cut transfer cost.
162
+ Blacklisted columns stay blacklisted: naming one in `--fields` yields no value and the
163
+ result still carries the blacklist `securityNotification`. A requested field that does
164
+ not exist in the result comes back as `null`.
165
+
166
+ #### Cell truncation (`--truncate`)
167
+
168
+ ```bash
169
+ dbcli query "SELECT sn, raw_response FROM bet_log" # table: 120-char default
170
+ dbcli query "SELECT sn, raw_response FROM bet_log" --truncate 40
171
+ dbcli query "SELECT sn, raw_response FROM bet_log" --no-truncate
172
+ ```
173
+
174
+ Table output truncates each serialized cell at 120 Unicode code points by default and
175
+ appends `…(+N chars)`; counting by code point keeps multi-byte characters and emoji
176
+ intact. `--truncate <n>` sets the width, `--no-truncate` disables it. Explicit truncation
177
+ flags are rejected with JSON, CSV, HTML, and `--ui` output.
178
+
179
+ #### Query from a file or stdin (`-f`)
180
+
181
+ ```bash
182
+ dbcli query -f report.sql
183
+ dbcli query --collection raw_bet_log -f - <<'EOF'
184
+ [{"$match": {"sn": {"$regex": "^SN0000"}}}, {"$group": {"_id": "$currency", "n": {"$sum": 1}}}]
185
+ EOF
186
+ ```
187
+
188
+ Avoids shell quoting entirely — the usual reason a Mongo pipeline containing `$regex`
189
+ or nested date objects fails. Supplying both `--query-file` and positional query text
190
+ is an error rather than a silent choice, and an empty file or empty stdin is refused.
191
+ `-f -` requires piped input: on an interactive terminal dbcli refuses immediately
192
+ instead of waiting silently for input that is never coming.
193
+
194
+ #### One-shot connection selection and read-only fan-out
195
+
196
+ Selection precedence is explicit `--use`, then `DBCLI_CONNECTION`, then the saved default.
197
+ `query`, `schema`, `list`, `export`, and `check` accept command-level `--use`; for other
198
+ commands use root-level `dbcli --use <name> <command>`. One-shot selectors never update the
199
+ saved default and require a v2 config. A legacy v1 single-connection config rejects them
200
+ instead of silently running its only connection.
201
+
202
+ An explicit comma-separated `--use primary,staging` fans one query out to several named
203
+ connections. `DBCLI_CONNECTION` always names one literal connection and never enables
204
+ fan-out. SQL permits `SELECT`, `SHOW`, `DESCRIBE`, and `EXPLAIN`; MongoDB permits filters and
205
+ read-only pipelines without top-level `$out` / `$merge`; Elasticsearch permits searches.
206
+ Redis, writes, `--recovery`, `--ui`, CSV, and HTML are rejected before execution. Each
207
+ connection keeps its own blacklist, limit metadata, audit entry, and error. Aggregate exit
208
+ codes are `0` when all succeed, `2` for mixed outcomes, and `1` when all fail or preflight
209
+ rejects the request.
210
+
211
+ #### Truncation is stated, not implied
212
+
213
+ When the query-only auto-limit trims the result, the table footer reads
214
+ `Rows: 1000 (truncated; limit 1000)`, `--format json` carries
215
+ `metadata.truncated` and `metadata.limit_applied`, and CSV appends a `#` comment line.
216
+ dbcli fetches one row past the cap to decide this, so a result of exactly 1000 rows is
217
+ reported as `truncated: false` — never infer truncation from a round row count.
218
+
149
219
  > **MongoDB notes:**
150
220
  > - SQL syntax is rejected — use JSON object (filter) or JSON array (pipeline)
151
221
  > - `--collection <name>` is required
152
- > - Auto-limit does not apply; use `$limit` in your pipeline if needed
222
+ > - Query-only auto-limit applies to filters and to pipelines without their own
223
+ > `$limit`; the applied cap and truncation are reported in the result metadata
153
224
 
154
225
  > **Redis notes:**
155
226
  > - The first token must be an allow-listed command (`GET`/`SET`/`HGET`/`HSET`/`DEL`/...). Unknown commands are refused.
@@ -661,9 +732,13 @@ dbcli export orders --no-limit --format jsonl # scroll the whole ind
661
732
  **Options:** `--format <json|jsonl|csv|html>` (required), `--output <path>`, `--force`, `--recovery`, `--collection <name>` (MongoDB collection) / `--index <name>` (Elasticsearch index; alias for `--collection`), `--limit <number>` (overrides auto-limit), `--no-limit` (Elasticsearch full-index scroll)
662
733
  **Permission:** query-only+ — SQL, MongoDB, and **(v1.22)** Elasticsearch.
663
734
 
735
+ If the query-only auto-limit would omit rows, export fails closed with exit code `1` and
736
+ writes no partial file. Re-run with `--no-limit` to export everything, or `--limit N` to
737
+ accept a bounded export explicitly. This applies to SQL, MongoDB, and Elasticsearch.
738
+
664
739
  The `html` format emits the same self-contained dashboard as `query --ui` (see [Interactive HTML dashboard](#interactive-html-dashboard)). Because `export` runs raw SQL (no snippet metadata), the HTML report is always rendered as a sortable / filterable table — no KPIs or charts. Use `dbcli q @<name> --format html` (or `--ui`) for the charted view.
665
740
 
666
- > **Elasticsearch export (v1.22):** pass a search DSL with `--index <index>` to export the hits, or pass an index name as the query to scroll the whole index via `match_all`. Default cap is 1000 rows; `--no-limit` streams the full index via scroll in batches. Index-level blacklist is checked before export and an audit record is written.
741
+ > **Elasticsearch export (v1.22):** pass a search DSL with `--index <index>` to export the hits, or pass an index name as the query to scroll the whole index via `match_all`. Default cap is 1000 rows; reaching it fails closed unless the caller explicitly uses `--limit N`, while `--no-limit` streams the full index via scroll in batches. Index-level blacklist is checked before export and an audit record is written.
667
742
 
668
743
  ### blacklist
669
744
 
@@ -722,6 +797,10 @@ separate `--snapshot` / `--against` workflow.
722
797
  dbcli diff --against-orm prisma/schema.prisma --format json
723
798
  dbcli diff --against-orm schema.normalized.json --orm-format json --format table
724
799
 
800
+ # Drizzle requires a PostgreSQL drizzle-kit v7 snapshot (generate it first)
801
+ drizzle-kit generate
802
+ dbcli diff --against-orm drizzle/meta/0001_snapshot.json --orm-format drizzle --format table
803
+
725
804
  # DDL accepts repeatable or comma-separated paths and real filesystem globs
726
805
  dbcli diff --against-orm "migrations/*.sql" --format markdown
727
806
  dbcli diff --against-orm migrations/base.sql,migrations/accounts.sql \
@@ -731,11 +810,60 @@ dbcli diff --against-orm migrations/base.sql,migrations/accounts.sql \
731
810
  dbcli diff --against-orm prisma/schema.prisma --ignore 'public.audit_*,public.Legacy'
732
811
  ```
733
812
 
813
+ ##### TypeORM
814
+
815
+ TypeORM entities are not parsed directly. `schema:log` prints the SQL that
816
+ `schema:sync` would execute without applying it; `-d` is the required data-source
817
+ path. Generate that DDL, then select the `typeorm` alias so the report is tagged
818
+ `ormSource: typeorm`:
819
+
820
+ ```bash
821
+ bunx typeorm schema:log -d <path/to/datasource> > schema.sql
822
+ dbcli diff --against-orm schema.sql --orm-format typeorm --format table
823
+ ```
824
+
825
+ With `--orm-format typeorm`, `typeorm_metadata` and `migrations` are
826
+ default-ignored and appear as `unmanaged` rather than scored drift. Passing a
827
+ TypeORM `.ts`, `.js`, `.mjs`, or `.cjs` source file is rejected with the
828
+ `schema:log` command to run. See the
829
+ [TypeORM CLI documentation](https://typeorm.io/docs/using-cli) and
830
+ [`SchemaLogCommand`](https://github.com/typeorm/typeorm/blob/master/src/commands/SchemaLogCommand.ts).
831
+
832
+ ##### Sequelize
833
+
834
+ Sequelize CLI does not provide a universal `db:migrate --dry-run`. Point the
835
+ project's existing Sequelize configuration at an empty scratch database, apply
836
+ the migrations there, and dump definitions without row data:
837
+
838
+ ```bash
839
+ # Configure Sequelize for an empty scratch database first
840
+ bunx sequelize-cli db:migrate
841
+
842
+ # PostgreSQL scratch database
843
+ pg_dump --schema-only <scratch-database> > schema.sql
844
+
845
+ # MySQL scratch database
846
+ mysqldump --no-data <database> > schema.sql
847
+
848
+ dbcli diff --against-orm schema.sql --orm-format sequelize --format json
849
+ ```
850
+
851
+ With `--orm-format sequelize`, `SequelizeMeta` is default-ignored and appears as
852
+ `unmanaged` rather than scored drift. Passing a Sequelize `.ts`, `.js`, `.mjs`,
853
+ or `.cjs` model file is rejected with the scratch-database and schema-only dump
854
+ recipe. See the
855
+ [Sequelize CLI migration command](https://github.com/sequelize/cli/blob/main/src/commands/migrate.js),
856
+ [PostgreSQL `pg_dump`](https://www.postgresql.org/docs/current/app-pgdump.html),
857
+ and [MySQL `mysqldump`](https://dev.mysql.com/doc/refman/8.4/en/mysqldump-definition-data-dumps.html)
858
+ references.
859
+
734
860
  | Option | Behavior |
735
861
  | :--- | :--- |
736
- | `--against-orm <paths>` | Repeatable or comma-separated input. DDL inputs support real filesystem globs; matches are deduplicated and put in deterministic path order, then parsed as one shared ordered context so an index in a later file can attach to a table declared in an earlier file. Prisma and normalized JSON accept exactly one file, and globs are rejected for those formats. |
737
- | `--orm-format prisma\|ddl\|json` | Override extension/content detection. Without it, dbcli detects Prisma, DDL, or normalized JSON from the path and content. |
738
- | `--ignore <globs>` | Comma-separated, case-sensitive table globs. Patterns match the qualified display identity (for example `public.Users`). `_prisma_migrations` is always unmanaged. |
862
+ | `--against-orm <paths>` | Repeatable or comma-separated input. DDL-family inputs (raw DDL, TypeORM, and Sequelize) support real filesystem globs; matches are deduplicated and put in deterministic path order, then parsed as one shared ordered context so an index in a later file can attach to a table declared in an earlier file. Prisma, normalized JSON, and Drizzle accept exactly one file, and globs are rejected for those formats. |
863
+ | Drizzle input | Run `drizzle-kit generate`, then pass the PostgreSQL drizzle-kit v7 snapshot at `drizzle/meta/<NNNN>_snapshot.json`. TypeScript ORM schema sources (`.ts` or `.TS`) are rejected with that snapshot-generation hint; dbcli does not parse them directly. |
864
+ | TypeORM / Sequelize input | Generate DDL with the ORM/database tooling, then pass the SQL file with the matching `typeorm` or `sequelize` alias. Entity/model source files are rejected rather than parsed. |
865
+ | `--orm-format prisma\|ddl\|json\|drizzle\|typeorm\|sequelize` | Override extension/content detection. The `typeorm` and `sequelize` aliases use the DDL adapter while preserving the source tag and ORM-specific default ignores. Without an override, dbcli detects Prisma, raw DDL, normalized JSON, or a Drizzle snapshot from the path and content. |
866
+ | `--ignore <globs>` | Comma-separated, case-sensitive table globs. Patterns match the qualified display identity (for example `public.Users`). `_prisma_migrations` is always unmanaged; the TypeORM alias additionally ignores `typeorm_metadata` and `migrations`, and the Sequelize alias additionally ignores `SequelizeMeta`. |
739
867
  | `--format json\|table\|markdown` | Select machine JSON, human table, or Markdown output. Markdown is available only in ORM drift mode. |
740
868
  | `--recovery` | On an I/O, configuration, empty-cache, invalid-format, or unsupported-engine failure, emit and save a structured recovery envelope. Invalid Prisma/DDL constructs normally become `unparsed` entries instead of throwing. |
741
869
 
@@ -783,9 +911,11 @@ another.
783
911
  columns, multi-schema datasource configuration, malformed declarations, unknown
784
912
  attributes, and unsupported native mappings are never guessed.
785
913
 
786
- Prisma and DDL constructs outside the supported subset are retained in
914
+ Prisma, DDL, and Drizzle constructs outside the supported subset are retained in
787
915
  `unparsed` with a `blocked:` reason. These entries are separate from scored drift:
788
916
  inspect and resolve them before treating an otherwise clean summary as complete.
917
+ Drizzle enums and other unsupported snapshot constructs therefore appear as blocked
918
+ `unparsed` entries rather than managed tables or columns.
789
919
  Multi-file DDL is consumed as one deterministic shared ordered statement context,
790
920
  so later `CREATE INDEX` statements can reference tables declared in earlier
791
921
  files. PostgreSQL `PARTITION BY` and MySQL/MariaDB table engine, charset, and