ZenStack CLI Reference
Usage
zen [options] [command]
ζ ZenStack is the modern data layer for TypeScript apps.
Documentation: https://zenstack.dev/docs
Options:
-v --version display CLI version
-h, --help display help for command
Commands:
generate [options] Run code generation.
migrate Run database schema migration related tasks.
db Manage your database schema during development.
info [path] Get information of installed ZenStack packages.
init [path] Initialize an existing project for ZenStack.
check [options] Check a ZModel schema for syntax or semantic errors.
format [options] Format a ZModel schema file.
help [command] display help for command
Sub Commands
generate
Run code generation plugins.
Usage: zen generate [options]
Run code generation plugins.
Options:
--schema <file> schema file (with extension .zmodel). Defaults to "zenstack/schema.zmodel" unless
specified in package.json.
-o, --output <path> default output directory for code generation
-w, --watch watch for changes and re-generate automatically
--lite also generate a lite version of schema without attributes
--lite-only only generate lite version of schema without attributes
--silent suppress all output except errors (default: false)
-h, --help display help for command
migrate
Run database schema migration related tasks.
Usage: zen migrate [options] [command]
Run database schema migration related tasks.
Options:
-h, --help display help for command
Commands:
dev [options] Create a migration from changes in schema and apply it to the database.
reset [options] Reset your database and apply all migrations, all data will be lost.
deploy [options] Deploy your pending migrations to your production/staging database.
status [options] Check the status of your database migrations.
resolve [options] Resolve issues with database migrations in deployment databases
help [command] display help for command
migrate dev
Create a migration from changes in schema and apply it to the database.
For development only. Do not use this command in production.
Usage: zen migrate dev [options]
Create a migration from changes in schema and apply it to the database.
Options:
--schema <file> schema file (with extension .zmodel). Defaults to "zenstack/schema.zmodel" unless specified in package.json.
-n, --name <name> migration name
--create-only only create migration, do not apply
--migrations <path> path that contains the "migrations" directory
--random-prisma-schema-name append a random UUID to the temporary Prisma schema filename (e.g., ~schema.<uuid>.prisma) to avoid collisions between concurrent runs sharing a working directory (default: false)
-h, --help display help for command
migrate reset
Reset your database and apply all migrations, all data will be lost.
Never run this command in production. It will drop all data in the database.
Usage: zen migrate reset [options]
Reset your database and apply all migrations, all data will be lost.
Options:
--schema <file> schema file (with extension .zmodel). Defaults to "zenstack/schema.zmodel" unless specified in package.json.
--force skip the confirmation prompt
--migrations <path> path that contains the "migrations" directory
--random-prisma-schema-name append a random UUID to the temporary Prisma schema filename (e.g., ~schema.<uuid>.prisma) to avoid collisions between concurrent runs sharing a working directory (default: false)
-h, --help display help for command
If there is a seed script defined in package.json, it will be run after the reset. Use --skip-seed to skip it.
migrate deploy
Deploy your pending migrations to your production/staging database.
Usage: zen migrate deploy [options]
Deploy your pending migrations to your production/staging database.
Options:
--schema <file> schema file (with extension .zmodel). Defaults to "zenstack/schema.zmodel" unless specified in package.json.
--migrations <path> path that contains the "migrations" directory
--random-prisma-schema-name append a random UUID to the temporary Prisma schema filename (e.g., ~schema.<uuid>.prisma) to avoid collisions between concurrent runs sharing a working directory (default: false)
-h, --help display help for command
migrate status
Check the status of your database migrations.
Usage: zen migrate status [options]
Check the status of your database migrations.
Options:
--schema <file> schema file (with extension .zmodel). Defaults to "zenstack/schema.zmodel" unless specified in package.json.
--migrations <path> path that contains the "migrations" directory
--random-prisma-schema-name append a random UUID to the temporary Prisma schema filename (e.g., ~schema.<uuid>.prisma) to avoid collisions between concurrent runs sharing a working directory (default: false)
-h, --help display help for command
migrate resolve
Resolve issues with database migrations in deployment databases.
Usage: zen migrate resolve [options]
Resolve issues with database migrations in deployment databases.
Options:
--schema <file> schema file (with extension .zmodel). Defaults to "zenstack/schema.zmodel" unless specified in package.json.
--migrations <path> path that contains the "migrations" directory
--applied <migration> record a specific migration as applied
--rolled-back <migration> record a specific migration as rolled back
--random-prisma-schema-name append a random UUID to the temporary Prisma schema filename (e.g., ~schema.<uuid>.prisma) to avoid collisions between concurrent runs sharing a working directory (default: false)
-h, --help display help for command
db
Manage your database schema during development.
Usage: zen db [options] [command]
Manage your database schema during development.
Options:
-h, --help display help for command
Commands:
push [options] Push the state from your schema to your database
seed [options] Seed the database
help [command] display help for command
db push
Push the state from your schema to your database.
Usage: zen db push [options]
Push the state from your schema to your database.
Options:
--schema <file> schema file (with extension .zmodel). Defaults to "zenstack/schema.zmodel" unless specified in package.json.
--accept-data-loss ignore data loss warnings
--force-reset force a reset of the database before push
--random-prisma-schema-name append a random UUID to the temporary Prisma schema filename (e.g., ~schema.<uuid>.prisma) to avoid collisions between concurrent runs sharing a working directory (default: false)
-h, --help display help for command
db pull
Introspect your database and generate a ZModel schema from it.
Usage: zen db pull [options]
Introspect your database.
Options:
--schema <file> schema file (with extension .zmodel). Defaults to "zenstack/schema.zmodel"
unless specified in package.json.
-o, --output <path> set custom output path for the introspected schema. If a file path is
provided, all schemas are merged into that single file. If a directory path
is provided, files are written to the directory and imports are kept.
--model-casing <pascal|camel|snake|none> set the casing of generated models (default: "pascal")
--field-casing <pascal|camel|snake|none> set the casing of generated fields (default: "camel")
--always-map always add @map and @@map attributes to models and fields (default: false)
--quote <double|single> set the quote style of generated schema files (default: "single")
--indent <number> set the indentation of the generated schema files (default: 4)
-h, --help display help for command
db seed
Usage: zen db seed [options]
Seed the database.
Options:
--no-version-check do not check for new version
-h, --help Show this help message
Seed script is configured under the "zenstack.seed" field in package.json.
E.g.:
{
"zenstack": {
"seed": "ts-node ./zenstack/seed.ts"
}
}
Arguments following -- are passed to the seed script. E.g.: "zen db seed -- --users 10"
info
Get information of installed ZenStack packages.
Usage: zen info [options] [path]
Get information of installed ZenStack.
Arguments:
path project path (default: ".")
Options:
-h, --help display help for command
init
Initialize an existing project for ZenStack.
Usage: zen init [options] [path]
Initialize an existing project for ZenStack.
Arguments:
path project path (default: ".")
Options:
-h, --help display help for command
check
Check a ZModel schema for syntax or semantic errors.
Usage: zen check [options]
Check a ZModel schema for syntax or semantic errors.
Options:
--schema <file> schema file (with extension .zmodel). Defaults to "zenstack/schema.zmodel" unless
specified in package.json.
-h, --help display help for command
format
Format a ZModel schema file.
Usage: zen format [options]
Format a ZModel schema file.
Options:
--schema <file> schema file (with extension .zmodel). Defaults to "zenstack/schema.zmodel" unless
specified in package.json.
-h, --help display help for command
proxy
Start the ZenStack proxy server. This command is aliased as studio too.
Usage: zen proxy [options]
Options:
--schema <file> schema file (with extension .zmodel). Defaults to "zenstack/schema.zmodel" unless specified in package.json.
-p, --port <port> port to run the proxy server on (default: 2311)
-o, --output <path> output directory for `zen generate` command
-d, --databaseUrl <url> database connection URL
-l, --logLevel <level...> Query log levels (e.g., query, error)
--no-version-check do not check for new version
-h, --help Show this help message
Overriding Default Options
Default Schema Location
You can override the default path that the CLI loads the schema by adding the following key to your package.json:
{
"zenstack": {
"schema": "path/to/your/schema.zmodel"
}
}
Default Output Directory
You can override the default code generation output path that the CLI uses by adding the following key to your package.json:
{
"zenstack": {
"output": "path/to/your/output/directory"
}
}