seppevs / migrate-mongo

A database migration tool for MongoDB in Node
MIT License
902 stars 160 forks source link

Use a custom template on migration creation #403

Closed bassochette closed 2 years ago

bassochette commented 2 years ago

Is your feature request related to a problem? Please describe. While creating migrations using typescript, I end up with untyped function and I need to type them every time.... That's kind of annoying

Describe the solution you'd like As a user I'd like to pass a parameter to provide a custom template mongo-migrate create <migration name> --template migrations-utils/template.ts

jamiter commented 2 years ago

Looking at the code, this is already possible:

https://github.com/seppevs/migrate-mongo/blob/323e9f423576bc693883251b907f0cc5da33fcea/lib/env/migrationsDir.js#L46-L49

You'll need to add a sample-migration.ts in your migrations directory and it will use it to create future migration files.

Now that I know it has this name, I also found it in the documentation: https://github.com/seppevs/migrate-mongo#overriding-the-sample-migration

Maybe if it was called something with template in the name I would have found it sooner (and you too...).

bassochette commented 2 years ago

Looking at the code, this is already possible:

https://github.com/seppevs/migrate-mongo/blob/323e9f423576bc693883251b907f0cc5da33fcea/lib/env/migrationsDir.js#L46-L49

You'll need to add a sample-migration.ts in your migrations directory and it will use it to create future migration files.

Now that I know it has this name, I also found it in the documentation: https://github.com/seppevs/migrate-mongo#overriding-the-sample-migration

Maybe if it was called something with template in the name I would have found it sooner (and you too...).

Nice catch, thanks a lot. I'll try that asap :)

bassochette commented 2 years ago

I'll close the issue since. thanks for you help @jamiter