DEV Community

Discussion on: Building a MongoDB migration system for NestJS with mongoose

bassochette profile image
Julien Prugne Author


I use to place it in a file called ts-compiler.js in a folder called src/migration-utils
You can take a look in the sample repo.

Then you can use as an option in the migration command invocations: --compiler=\"ts:./src/migrations-utils/ts-compiler.js\"

It's in the sample repo, but I'll share the migration commands in the package.json here:

"migrate:create": "migrate create --template-file ./src/migrations-utils/template.ts --migrations-dir=\"./src/migrations\" --compiler=\"ts:./src/migrations-utils/ts-compiler.js\"",
"migrate:up": "migrate --migrations-dir=\"./src/migrations\" --compiler=\"ts:./src/migrations-utils/ts-compiler.js\" up",
"migrate:down": "migrate --migrations-dir=\"./src/migrations\" --compiler=\"ts:./src/migrations-utils/ts-compiler.js\" down"
Enter fullscreen mode Exit fullscreen mode

Hope this nugget will help you :)