@carllee1983/dbcli 1.37.0 → 1.38.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.
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor/rules/dbcli.mdc +192 -280
- package/.cursor/skills/dbcli/reference.md +131 -2
- package/.cursor-plugin/plugin.json +1 -1
- package/.github/skills/dbcli/SKILL.md +192 -280
- package/.github/skills/dbcli/reference.md +131 -2
- package/CHANGELOG.md +22 -0
- package/assets/SKILL.md +192 -280
- package/assets/SKILL.zh-TW.md +211 -330
- package/assets/reference.md +131 -2
- package/dist/cli.mjs +11866 -681
- package/dist/core.mjs +1 -1
- package/gemini-extension.json +1 -1
- package/package.json +1 -1
- package/plugins/dbcli-agent/skills/dbcli/SKILL.md +192 -280
- package/plugins/dbcli-agent/skills/dbcli/reference.md +131 -2
- package/skills/dbcli/SKILL.md +192 -280
- package/skills/dbcli/reference.md +131 -2
package/assets/reference.md
CHANGED
|
@@ -1147,8 +1147,8 @@ Output reports: writer enabled/disabled, last write result, file-lock state, rot
|
|
|
1147
1147
|
### verify
|
|
1148
1148
|
|
|
1149
1149
|
Run a verification scenario. `verify` **runs** verification scenarios (safe-backfill,
|
|
1150
|
-
migration) and never executes writes/DDL. `verification` **inspects and manages**
|
|
1151
|
-
local result artifacts those scenarios produce under `.dbcli/verification/`.
|
|
1150
|
+
migration, rollback) and never executes writes/DDL. `verification` **inspects and manages**
|
|
1151
|
+
the local result artifacts those scenarios produce under `.dbcli/verification/`.
|
|
1152
1152
|
|
|
1153
1153
|
```bash
|
|
1154
1154
|
# Preflight (default): read-only guards + the exact after-write command. No artifact.
|
|
@@ -1233,6 +1233,135 @@ cannot be fully parsed under this contract (unterminated quotes, unsupported esc
|
|
|
1233
1233
|
or more than three parts) are blocked before the after-write assertion with a
|
|
1234
1234
|
"could not be parsed" reason, distinct from the `must match --table` mismatch reason.
|
|
1235
1235
|
|
|
1236
|
+
#### `verify rollback`
|
|
1237
|
+
|
|
1238
|
+
(v1.37.0+) Preflight or after-write verification for an **externally-applied rollback** —
|
|
1239
|
+
confirming that after you reverted a change the database is back to the expected prior
|
|
1240
|
+
state. **This command never executes the reverting statement** — it analyzes it, runs
|
|
1241
|
+
read-only guards, and (in after-write mode) records evidence after you apply the rollback
|
|
1242
|
+
externally. One scenario covers both schema and data rollbacks via a required
|
|
1243
|
+
`--kind <ddl|dml>` selector:
|
|
1244
|
+
|
|
1245
|
+
- `--kind ddl` — revert a schema migration. `--statement` is a single `ALTER TABLE`
|
|
1246
|
+
(e.g. dropping a column a forward migration added). Reuses the `migration` DDL gates.
|
|
1247
|
+
- `--kind dml` — revert a data change. `--statement` is a single `UPDATE` that restores
|
|
1248
|
+
prior values. Reuses the `safe-backfill` UPDATE plan gates.
|
|
1249
|
+
|
|
1250
|
+
```bash
|
|
1251
|
+
# Schema rollback (--kind ddl) — preflight, then record evidence after applying it.
|
|
1252
|
+
dbcli verify rollback \
|
|
1253
|
+
--kind ddl \
|
|
1254
|
+
--table users \
|
|
1255
|
+
--statement "ALTER TABLE users DROP COLUMN verified_at" \
|
|
1256
|
+
--verify-query "SELECT count(*)::int AS n FROM information_schema.columns WHERE table_name = 'users' AND column_name = 'verified_at'" \
|
|
1257
|
+
--expect "value == 0"
|
|
1258
|
+
dbcli verify rollback --kind ddl ... --after-write
|
|
1259
|
+
|
|
1260
|
+
# Data rollback (--kind dml) — revert an UPDATE, then read back.
|
|
1261
|
+
dbcli verify rollback \
|
|
1262
|
+
--kind dml \
|
|
1263
|
+
--table users \
|
|
1264
|
+
--statement "UPDATE users SET status = NULL WHERE status = 1" \
|
|
1265
|
+
--verify-query "SELECT count(*)::int AS n FROM users WHERE status = 1" \
|
|
1266
|
+
--expect "value == 0"
|
|
1267
|
+
dbcli verify rollback --kind dml ... --after-write
|
|
1268
|
+
|
|
1269
|
+
# JSON for agents (both kinds).
|
|
1270
|
+
dbcli verify rollback --kind ddl ... --format json
|
|
1271
|
+
```
|
|
1272
|
+
|
|
1273
|
+
| Option | Required | Description |
|
|
1274
|
+
| --- | --- | --- |
|
|
1275
|
+
| `--kind <ddl\|dml>` | yes | Reverting-statement grammar: `ddl` (single `ALTER TABLE`) or `dml` (single `UPDATE`). Invalid value fails closed before any DB connection. |
|
|
1276
|
+
| `--table <table>` | yes | Table affected by the rollback. |
|
|
1277
|
+
| `--statement <sql>` | yes | Proposed reverting statement, analyzed but never executed. |
|
|
1278
|
+
| `--verify-query <sql>` | yes | Plain `SELECT` for post-rollback read-back verification. |
|
|
1279
|
+
| `--expect <expr>` | yes | Assertion expression for the read-back result. |
|
|
1280
|
+
| `--after-write` | no | Run the post-rollback assertion and write a v1 artifact. |
|
|
1281
|
+
| `--format <table\|json>` | no | Output format, default `table`. |
|
|
1282
|
+
| `--subject-name <name>` | no | Artifact subject name. Default is the table name. |
|
|
1283
|
+
| `--summary <text>` | no | Optional artifact summary override. |
|
|
1284
|
+
|
|
1285
|
+
A single `--statement` flag is used for both kinds (instead of reusing `--ddl` / `--query`)
|
|
1286
|
+
to keep the dual-kind surface honest. The guard sequence, statuses (`ready`/`blocked` in
|
|
1287
|
+
preflight; `verified` / `not_verified` / `blocked` / `indeterminate` in after-write), and
|
|
1288
|
+
exit codes are identical to the other two scenarios. **MVP restrictions:** DML rollback is
|
|
1289
|
+
`UPDATE`-only (INSERT/DELETE reverts deferred); DDL rollback is single `ALTER TABLE` only,
|
|
1290
|
+
using the same identifier contract as `verify migration`.
|
|
1291
|
+
|
|
1292
|
+
The artifact schema is unchanged: a rollback reuses the existing subject kinds —
|
|
1293
|
+
`--kind ddl` → `migration`, `--kind dml` → `backfill` — and records its provenance via
|
|
1294
|
+
`subject.command = "verify rollback"` plus the summary, so `verification` filters and
|
|
1295
|
+
retention are unaffected.
|
|
1296
|
+
|
|
1297
|
+
#### `verify constraint`
|
|
1298
|
+
|
|
1299
|
+
(v1.38.0+) Preflight or after-write verification that a **data-integrity invariant holds**
|
|
1300
|
+
across your change — foreign-key consistency, NOT NULL coverage, uniqueness, or a custom
|
|
1301
|
+
violation query. **This command never executes a write** — it only runs read-only
|
|
1302
|
+
`COUNT(*)` violation queries against the live table and (in after-write mode) records
|
|
1303
|
+
evidence. Four check kinds, selected by `--check`:
|
|
1304
|
+
|
|
1305
|
+
- `--check fk` — counts orphaned rows in the child table. Requires `--column` (the child
|
|
1306
|
+
FK column) and `--references <table.column>` (the referenced parent column).
|
|
1307
|
+
- `--check not-null` — counts rows where the column value is NULL. `--column` is
|
|
1308
|
+
repeatable; each column is checked independently.
|
|
1309
|
+
- `--check unique` — counts duplicate values in one or more columns. `--column` is
|
|
1310
|
+
repeatable; all listed columns are combined into a single uniqueness check.
|
|
1311
|
+
- `--check custom` — executes the caller-supplied `--violation-query <sql>`, which must
|
|
1312
|
+
be a plain read-only `SELECT` returning a single integer count of violations.
|
|
1313
|
+
|
|
1314
|
+
```bash
|
|
1315
|
+
# FK preflight — verify no orphaned orders before a migration.
|
|
1316
|
+
dbcli verify constraint \
|
|
1317
|
+
--table orders \
|
|
1318
|
+
--check fk \
|
|
1319
|
+
--column customer_id \
|
|
1320
|
+
--references customers.id
|
|
1321
|
+
|
|
1322
|
+
# NOT NULL preflight — verify the column is fully populated.
|
|
1323
|
+
dbcli verify constraint \
|
|
1324
|
+
--table users \
|
|
1325
|
+
--check not-null \
|
|
1326
|
+
--column email
|
|
1327
|
+
|
|
1328
|
+
# After the write is applied externally — record evidence.
|
|
1329
|
+
dbcli verify constraint --table orders --check fk --column customer_id \
|
|
1330
|
+
--references customers.id --after-write
|
|
1331
|
+
|
|
1332
|
+
# JSON output for agents.
|
|
1333
|
+
dbcli verify constraint --table users --check not-null --column email --format json
|
|
1334
|
+
```
|
|
1335
|
+
|
|
1336
|
+
| Option | Required | Description |
|
|
1337
|
+
| --- | --- | --- |
|
|
1338
|
+
| `--table <table>` | yes | Table the invariant is checked on. |
|
|
1339
|
+
| `--check <kind>` | yes | Constraint kind: `fk` \| `not-null` \| `unique` \| `custom`. |
|
|
1340
|
+
| `--column <name>` | yes (fk/not-null/unique) | Column to check. Repeatable for `not-null`/`unique`; the child FK column for `fk`. |
|
|
1341
|
+
| `--references <table.column>` | yes (fk only) | Referenced `<table>.<column>` for the FK parent lookup. |
|
|
1342
|
+
| `--violation-query <sql>` | yes (custom only) | Read-only `SELECT` returning a single integer count of violations. |
|
|
1343
|
+
| `--allow-preexisting` | no | Tolerate pre-existing violations: verified when `count ≤ --baseline` (default: `false`). |
|
|
1344
|
+
| `--baseline <n>` | no | Baseline violation count measured at preflight (use with `--allow-preexisting`). |
|
|
1345
|
+
| `--after-write` | no | Re-run the violation count and write a v1 verification artifact. |
|
|
1346
|
+
| `--format <table\|json>` | no | Output format, default `table`. |
|
|
1347
|
+
| `--subject-name <name>` | no | Artifact subject name. Default is the table name. |
|
|
1348
|
+
| `--summary <text>` | no | Optional artifact summary override (after-write mode). |
|
|
1349
|
+
|
|
1350
|
+
**Verdict rules.** Preflight returns `ready` or `blocked`; **`ready` is not `verified`**.
|
|
1351
|
+
After-write maps the violation count to `verified` (violations ≤ threshold) or
|
|
1352
|
+
`not_verified` (violations > threshold), and a failed guard to `blocked`; a query error
|
|
1353
|
+
yields `indeterminate`. The default threshold is `0` (strict: zero violations allowed).
|
|
1354
|
+
With `--allow-preexisting`, the threshold is the `--baseline` count captured at preflight,
|
|
1355
|
+
so the no-regression rule passes as long as the after-write count does not exceed the
|
|
1356
|
+
preflight count.
|
|
1357
|
+
|
|
1358
|
+
**MVP restrictions.** SQL engines only (PostgreSQL / MySQL / MariaDB — requires an active
|
|
1359
|
+
`--config` connection). FK checks support a single child column; composite FK constraints
|
|
1360
|
+
are not yet supported. The command never executes any write or DDL statement.
|
|
1361
|
+
|
|
1362
|
+
The artifact uses `subject.kind = 'table'` and `subject.command = 'verify constraint'`,
|
|
1363
|
+
so `verification` filters and retention are unaffected by the new scenario.
|
|
1364
|
+
|
|
1236
1365
|
### verification
|
|
1237
1366
|
|
|
1238
1367
|
(v1.33.0+) Local **VerificationArtifact** inspection and lifecycle surface over
|