@dbsp/cli
v1.0.1
Published
CLI tools for db-semantic-planner — REPL, schema generation, DDL provisioning
Maintainers
Readme
@dbsp/cli
CLI tools for @dbsp — interactive REPL, schema verification, DDL provisioning, and batch execution.
Installation
# As a dev dependency (recommended)
pnpm add -D @dbsp/cli
# Or globally
npm install -g @dbsp/cliQuick Start
# Interactive REPL with NQL tab-completion
npx dbsp repl --schema ./dbsp.schema.ts --db postgres://user:pass@localhost/mydb
# Verify schema against a live database (drift detection)
npx dbsp verify --schema ./dbsp.schema.ts --db postgres://user:pass@localhost/mydb
# Push schema changes to the database
npx dbsp push --schema ./dbsp.schema.ts --db postgres://user:pass@localhost/mydb
# Generate DDL SQL for provisioning
npx dbsp generate ddl --schema ./dbsp.schema.ts -o ./generatedCommands
| Command | Description |
|---------|-------------|
| dbsp repl | Interactive REPL with NQL syntax, tab-completion, and query history |
| dbsp verify | Compare schema against live database; exit code 1 on drift |
| dbsp push | Apply schema changes (DDL provisioning) with advisory lock |
| dbsp migrate | Generate and apply UP/DOWN migration files |
| dbsp generate ddl | Generate SQL CREATE TABLE statements for provisioning |
| dbsp introspect | Generate schema.ts from database introspection |
Key features
- REPL with completion — Tab-complete table names, columns, NQL keywords, and relation paths
- Query history — Persistent history across sessions
- Batch mode — Use
repl --evalfor single queries orrepl --inputfor batch files - DDL provisioning —
pushcomputes schema diff and applies the minimum required DDL - Destructive-change safety — Warns before dropping columns or tables;
--forcerequired - Drift detection —
verifycompares live introspection against declared schema - Migration tracking —
migrategenerates UP/DOWN migration files with advisory locks - JSON output —
--jsonflag on most commands for CI pipeline integration
Documentation
License
MIT
