-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom migration file option to up #251
base: master
Are you sure you want to change the base?
Conversation
bin/migrate-mongo.js
Outdated
@@ -58,7 +58,8 @@ program | |||
program | |||
.command("up") | |||
.description("run all pending database migrations") | |||
.option("-f --file <file>", "use a custom config file") | |||
.option("-c --custom <custom>", "use a custom config file") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description of this option is the same as the above, maybe it was a mistake when copying the line above to add a new option...
The correct description wouldn't be "migration file to run"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A typo. Fixed.
// console.log("some", global.options); | ||
if (global.options.custom) { | ||
await migrateItem( | ||
{ fileName: global.options.custom, appliedAt: "CUSTOM" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bdcorps IMO it would be better if we stored the date in appliedAt field. It will be useful to check when this particular migration was applied. Perhaps a boolean field will be better to differentiate between the regular and custom migration.
@@ -28,6 +28,7 @@ Usage: migrate-mongo [options] [command] | |||
|
|||
Options: | |||
|
|||
-c, --custom specify a custom migration file (only for up) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bdcorps having a down custom migration also will be super useful. Specially for some quick hot fixes. See if you can consider a down migration support for custom migration.
this feature should be useful. |
@seppevs would you be able to review this? Also, if you're not happy with this approach, could you suggest some alternatives? |
@seppevs any chance this could be merged? would be super useful |
@shweshi @MaikeMota bump |
Added with modifications in |
Adds a
custom
switch toup
command as presented in #250. Runningmigrate-mongo up --custom migrate1.js
allows you to bypass the database changelog checking to immediately apply the migration. Very useful for testing migration scripts.Checklist
npm test
passes and has 100% coverage