yarn db:migrate
yarn db:migrate performs three steps in sequence:
yarn modules:prepare– regenerates module registries, dependency injection bindings, and entity ID maps.tsx scripts/mikro-modules.ts apply– runs MikroORM migrations for every enabled module in alphabetical order.tsx packages/cli/src/bin.ts entities install --global– ensures global custom entity and field definitions are synchronized.
Usage
yarn db:migrate
The command relies on DATABASE_URL for database connectivity.
When to Run
- After pulling new migrations from version control.
- Immediately after
yarn db:generateto apply fresh diffs. - During CI to guarantee the schema is aligned before running tests or seeding fixtures.
Output
The script prints progress for each module (auth: applied, directory: applied, …) followed by entity install stats. Any failure aborts the remaining steps so you can resolve the issue safely.
Troubleshooting
- Migration errors — inspect the failing module’s migration file in
packages/<module>/src/modules/<module>/migrations. You can retry once the issue is resolved. - Custom entity sync errors — ensure Redis (if configured) is reachable so cache invalidation succeeds, or run
yarn mercato entities install --forceafterwards. - Long-running migrations — consider running
yarn db:migratewithNODE_ENV=productionpointing to a managed database that has appropriate resources.