Migrations
Use the CLI migration commands to keep SQL and Mongo schema changes deterministic.Core commands
make:migrationmigrate:runmigrate:rollbackmigrate:resetmigrate:freshmigrate:status
Environment targets
Use--test and connection flags for CI-safe migration execution.
Stability reminders
- Guarded destructive operations (
reset,fresh) require production protection. --all-connectionsremains SQL-only (mysql,pg,sqlite).- Use
--mongoonly when explicitly targeting Mongo.
Safety
Prefer backup-and-verify for production paths and explicit environment control.Model-first rule
Use models as the source of truth first, then generate migrations from them. When you need physical foreign keys, composite indexes, or named relational constraints, define them instatic database and then run make:migration.
Timestamp columns
Timestamp semantics stay instatic schema, not static database.
column("timestamp")keeps the legacy ORM default:- SQL runtime timestamp column
- current-time default unless you opt out
- use
{ useTz: true }when PostgreSQL must emitTIMESTAMPTZ - use
{ defaultNow: false }for business timestamps that must start empty until the application sets them column("softDeletes")never defaults to the current time