Command Examples
Examples assume DATABASE_URL is set; otherwise migration commands use file:./dev.db. Migration names are <YYYYMMDDHHMMSS>_<slug>, the file name without .sql.
Migration Commands
migrate
tsorm migrate # generate and apply, named init/update by default
tsorm migrate --name add_profile # name the migration
tsorm migrate --name add_tags --create-only # write the file without applying it2
3
--create-only still performs earlier drift/reset checks and applies existing pending migrations; see Options. Rebuild from an empty state, discarding all data:
tsorm migrate --reset --forcedeploy
Apply pending migrations, for example in a release pipeline:
tsorm deployCheck readiness without applying anything; exits 1 when the database is not up to date:
tsorm deploy --checkresolve
resolve edits history without executing migration-file SQL or undoing DDL; it also registers baselines. After a failure, record it by outcome:
tsorm resolve --applied 20260109120000_add_tags # finished by hand, record as applied
tsorm resolve --rolled-back 20260109120000_add_tags # partial changes already undone; allow deploy to retry2
Sync Commands
diff
Print the SQL between two sources without modifying the business database; may use a shadow database. --from accepts migrations, database, or empty; --to accepts schema or database:
tsorm diff # migration history -> models
tsorm diff --from database # live database -> models
tsorm diff --from empty > init.sql # full table-creation SQL2
3
Summarize differences only, exiting 2 when there are any:
tsorm diff --checkpush
Bring the database in line with the models directly, without migration files — suited to local prototyping:
tsorm push # sync the structure differences directly
tsorm push --reset --force # clear the database first, then sync2
Schema Tooling Commands
validate
Check the schema file and report the model count:
tsorm validate # check the default schema.orm
tsorm validate --schema ./db/schema.orm # check a specific file2
generate
Write the client to the default generated/client.ts:
tsorm generate
tsorm generate --schema ./db/schema.orm --out ./src/db/client.ts # choose the schema and output path2
Next Steps
- Options & Behavior: what each flag does and when a confirmation is asked
- Versioned Migrations: the migration workflow behind
migrate,deploy, andresolve