Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

bdcorps
Copy link

@bdcorps bdcorps commented Sep 12, 2020

Adds a custom switch to up command as presented in #250. Running migrate-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
  • README.md is updated

@coveralls
Copy link

coveralls commented Sep 12, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling 43a9e88 on bdcorps:master into 17a3994 on seppevs:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 4ad156a on bdcorps:master into 17a3994 on seppevs:master.

@@ -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")
Copy link

@MaikeMota MaikeMota Oct 2, 2020

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"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A typo. Fixed.

lib/env/database.js Show resolved Hide resolved
// console.log("some", global.options);
if (global.options.custom) {
await migrateItem(
{ fileName: global.options.custom, appliedAt: "CUSTOM" },
Copy link

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)
Copy link

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.

@RulyAnggriawan
Copy link

this feature should be useful.
request for custom up and custom down :)

@wyardley
Copy link

@seppevs would you be able to review this? Also, if you're not happy with this approach, could you suggest some alternatives?

@stascnb
Copy link

stascnb commented Sep 12, 2022

@seppevs any chance this could be merged? would be super useful

@stascnb
Copy link

stascnb commented Sep 12, 2022

@shweshi @MaikeMota bump

@theogravity
Copy link

Added with modifications in migrate-mongo-alt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants