CLI Commands

Stabilize CLI v3.2.0 — 31 commands with shorthand aliases

The CLI is versioned independently of the ORM: this is the version of the stabilize-cli package, which is not the same number as the stabilize-orm release it depends on. This release bundles stabilize-orm@3.2.x and runs on Node.js 22.18+ as well as Bun — one bundle, with the SQLite driver chosen at run time. Under Node your project needs "type": "module", because the CLI imports your .ts files directly and Node would otherwise treat them as CommonJS. Every command works against MongoDB as well, with the single exception of query — a document command is not a string, so there is nothing for it to run.

Generate

generate:model <name> [fields...]g:m

Generate a model file. Pass columns as field:type.

terminal
❯stabilize-cli generate:model User name:string email:string age:int --versioned
generate:migration <name>g:mg

Generate a migration JSON from an existing model.

terminal
❯stabilize-cli generate:migration User
generate:seed <name>g:s

Generate a seed file with sample data.

terminal
❯stabilize-cli generate:seed User --count 10
generate:api <name>g:a

Generate REST API scaffold. Creates model if missing.

terminal
❯stabilize-cli generate:api Product --prefix /v1
generate:all <name> [fields...]g:x

Generate model + migration + seed together.

terminal
❯stabilize-cli generate:all Product name:string price:decimal --count 10
generate:test <name>g:t

Generate vitest test file with CRUD stubs.

terminal
❯stabilize-cli generate:test User

Migrate

migrate

Apply all pending migrations.

terminal
❯stabilize-cli migrate
migrate:rollback

Roll back the most recent migration.

terminal
❯stabilize-cli migrate:rollback
migrate:fresh

Drop all tables and re-run migrations. No seed.

terminal
❯stabilize-cli migrate:fresh --force
migrate:status

Detailed migration status with timestamps.

terminal
❯stabilize-cli migrate:status
migrate:pending

Show only pending migrations.

terminal
❯stabilize-cli migrate:pending
migrate:auto

GORM-style auto migrate: create tables, add missing columns and indexes. Never deletes.

terminal
❯stabilize-cli migrate:auto
seed

Run all pending seed files. Applied seeds are tracked in a stabilize_seed_history table, so a seed that already ran is not run twice.

terminal
❯stabilize-cli seed

Database

db:drop

Drop all tables.

terminal
❯stabilize-cli db:drop --force
db:reset

Drop, migrate, and seed in one command.

terminal
❯stabilize-cli db:reset --force
db:truncate [table]

Truncate a specific table or all tables.

terminal
❯stabilize-cli db:truncate users --force
db:backup

Backup database to timestamped file.

terminal
❯stabilize-cli db:backup --output ./backups
db:restore <file>

Restore from backup file.

terminal
❯stabilize-cli db:restore backups/backup.db --force
db:tables

List all tables with row counts.

terminal
❯stabilize-cli db:tables
db:size

Database size statistics.

terminal
❯stabilize-cli db:size
db:diff

Compare models vs database schema.

terminal
❯stabilize-cli db:diff
db:consoledb:sql

Interactive SQL REPL.

terminal
❯stabilize-cli db:console
db:table:info <table>

Show column details for a specific table.

terminal
❯stabilize-cli db:table:info users

Model & Config

model:validate

Validate all model files for errors.

terminal
❯stabilize-cli model:validate
model:info <name>

Show columns, relations, scopes for a model.

terminal
❯stabilize-cli model:info User
config:init

Scaffold a starter config/database.ts file.

terminal
❯stabilize-cli config:init --type postgres

Diagnostics

status

Migration and seed status with health check.

terminal
❯stabilize-cli status
health

Database and cache health check.

terminal
❯stabilize-cli health
health:json

JSON output for CI/CD automation.

terminal
❯stabilize-cli health:json
query <sql>

Execute raw SQL and display results.

terminal
❯stabilize-cli query 'SELECT * FROM users LIMIT 5'
info

CLI version, runtime, platform info.

terminal
❯stabilize-cli info