CLI Reference
31 commands. Runs on Node.js and Bun — install globally, or use npx / bunx.
The CLI is versioned independently of the ORM. This release bundles stabilize-orm@3.2.x and requires it — a project still on 2.x is told to upgrade rather than failing from inside the bundle.
It ships as one JavaScript bundle with no native dependencies, so the same install runs on Node.js 22.18+ and Bun 1.3+. The SQLite driver is chosen at run time — whichever of node:sqlite or bun:sqlite the runtime provides — and the other four backends are identical on both.
Running under Node.js
The CLI imports your config/database.ts, models/*.ts and the rest of your project at run time, and Node decides how to treat a .ts file by looking at the nearest package.json. Without "type": "module" it treats yours as CommonJS, so the import statements in your own files fail before any command runs:
Add "type": "module" to your project's package.json and every command works unchanged. Bun detects module syntax on its own, so Bun projects need nothing. Node 22.18 is the floor because that is where Node loads TypeScript by default.
MongoDB
Every command below works against a document backend as well, with one exception noted at the end. Where a command says “table”, MongoDB has a collection; where it says “row”, there is a document. Concretely:
db:tables,db:table:info,db:sizeanddb:difflist and describe collections rather than tables.db:truncate,db:dropanddb:resetclear collections;db:backupanddb:restoreround-trip documents, preserving_idand realDatevalues.db:consolebecomes a document console: it takescollections,find <collection> [filter]and any JSON command document.status,migrate:status,migrate:pending, seeding andmigrate:autoreport and act on collections.queryis the exception. MongoDB has no SQL to run, so it says so and points you atdb:tables,db:table:infoanddb:consolerather than failing withMONGO_UNSUPPORTEDafter you have already written the statement.
Shorthand Aliases
Every generate command has short aliases:
Generate
generate:model <name> [fields...]g:mGenerate a model file. Pass columns as field:type pairs.
generate:migration <name>g:mgGenerate a migration JSON file from an existing model.
generate:seed <name>g:sGenerate a seed file with sample data from model columns.
generate:api <name>g:aGenerate REST API scaffold with CRUD routes. Creates model if missing.
generate:all <name> [fields...]g:xGenerate model + migration + seed in one command.
generate:test <name>g:tGenerate a vitest test file with CRUD test stubs for a model.
Migrate
migrateApply all pending migrations from migrations/ directory.
migrate:rollbackRoll back the most recent migration using down SQL.
migrate:freshDrop all tables and re-run migrations. No seed.
migrate:statusShow detailed migration status with applied timestamps.
migrate:pendingShow only pending (not yet applied) migrations.
migrate:autoGORM-style auto migrate: create tables, add missing columns and indexes. Never deletes. Reads the models the project itself loaded, and reports any model whose table could not be created.
Seed
seedRun all pending seed files. Tracks applied seeds in database.
Database
db:dropDrop all tables. SQLite deletes the file.
db:resetDrop all tables, re-run migrations, and seed. Full reset.
db:truncate [table]Truncate a specific table or all tables.
db:backupBackup database. SQLite copies .db file; others export to JSON.
db:restore <file>Restore from a .db (SQLite) or .json backup file.
db:tablesList all tables with row counts.
db:sizeShow database file size and per-table row counts.
db:diffCompare model definitions against database tables. Shows missing/extra.
db:consoledb:sqlInteractive SQL REPL. Type 'tables' to list, 'exit' to quit.
db:table:info <table>Show detailed column info for a specific table.
Model
model:validateValidate all model files for errors (missing columns, types, etc).
model:info <name>Show detailed model metadata: columns, relations, scopes.
Config
config:initScaffold a starter config/database.ts file.
Diagnostics
statusShow migration and seed status with health check.
healthCheck database and cache connectivity with latency.
health:jsonHealth check with JSON output for CI/CD automation.
query <sql>Execute a raw query and display the results. On MongoDB the argument is a document command, such as {"find": "users"}.
-V, --versionPrint the CLI version and exit. Reads it from the manifest, so it cannot drift from the published package.
infoShow CLI version, runtime, platform, and all commands.
Confirmation & Safety
Commands that destroy data — migrate:fresh, db:drop, db:reset, db:truncate and db:restore — ask before they act:
Anything other than y aborts and changes nothing. With no terminal attached — a CI runner, a piped script, docker run without -t — there is nobody to answer, so the CLI refuses rather than waiting forever on a question that can never be answered:
--force is how you say yes from a script
Every one of these commands takes -f, --force, which skips the prompt entirely. That is the supported way to run a destructive command unattended — nothing else opts in, so an accidental db:drop in a pipeline stops instead of taking your data with it.