LogoZonai

zonai db

Database management subcommands — migrations, admin accounts, email, and logs.

Direct database operations — migrations, admin accounts, email testing, and data management. Most subcommands work directly on the SQLite file without a running server.

db migrate#

generate#

Generate SQL migration files from schema changes:

zonai db migrate generate --name add-status-column
zonai db migrate gen -n add-status-column   # aliases: g, gen
zonai db migrate generate --dry-run          # preview SQL without writing files

See Generating Migrations.

apply#

Apply all pending migrations to the database:

zonai db migrate apply   # alias: up

See Applying Migrations.

db admin#

add#

Create an admin account in an auth table:

zonai db admin add --email admin@example.com --password secret123
zonai db admin add -e admin@example.com -p secret123 --data '{"name":"Admin"}'
FlagShortDescription
--email-eAdmin email address (required)
--password-pAdmin password (required)
--data-dExtra JSON fields to merge into the row
--no-verifySkip email verification for this account

list#

List every admin account (id, email, and any other non-secret columns — never the password hash):

zonai db admin list
zonai db admin ls   # alias

reset-password#

Reset an existing admin account's password. Use this to recover a deployment where an admin account exists but nobody has the password:

zonai db admin reset-password --email admin@example.com --password newSecret123
zonai db admin reset -e admin@example.com -p newSecret123   # alias
FlagShortDescription
--email-eAdmin email address (required)
--password-pNew admin password (required)

remove#

Remove an existing admin account. Makes add recoverable — a removed email can be re-added later:

zonai db admin remove --email admin@example.com
zonai db admin rm -e admin@example.com   # aliases: rm, delete
FlagShortDescription
--email-eAdmin email address (required)

See Admin Accounts.

db email#

test#

Send a test email to verify SMTP configuration:

zonai db email test --to me@example.com
zonai db email test -t me@example.com --template password_reset

template create#

Create a new custom email template file:

zonai db email template create order_confirmation

See Custom Templates.

db logs#

clear#

Delete all records from the _log table:

zonai db logs clear   # aliases: delete, rm

Useful in development when logs have grown too large.

db clear#

Delete the SQLite database file entirely:

zonai db clear          # prompts for confirmation
zonai db clear --yes    # skip confirmation (alias: -y)
zonai db clear --reset  # alias

Destructive — all data is lost. Migrations re-apply on next server start. Use in development to reset to a clean state.