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
Enable rollback of all scripts from same migration #331
base: master
Are you sure you want to change the base?
Conversation
bc4bbcb
to
aabc4bf
Compare
This feature is very interesting! |
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.
To understand well, you don't use mongo's sessions to rollback but run down scripts ?
Anyway the code looks clear to me :)
const downgraded = []; | ||
const statusItems = await status(db); | ||
const appliedItems = statusItems.filter(item => item.appliedAt !== "PENDING"); | ||
const lastAppliedItem = _.last(appliedItems); | ||
|
||
let itemsToRollback = []; |
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.
To avoid mutability
let itemsToRollback = []; | |
const itemsToRollback = isBlockRollback && lastAppliedItem.migrationBlock ? appliedItems.filter(item => item.migrationBlock === lastAppliedItem.migrationBlock).reverse() : [lastAppliedItem] |
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.
I will take this into account in a next PR if it's ok for you as I will make a proposal of improvement for up & down commands.
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.
Here it is: ftreguer#1
I will modify the base branch once this one will be merged into master.
appliedAt: new Date(), | ||
}, | ||
{ | ||
fileName: "20160609113224-second_migration.js", |
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.
You should change the timestamp of second migration as currently the first ends with ...3224
and the last with ...3225
.
The second migration should follow a chronological order as the lib sorts the migration that way. So :
...3224
: 1st migration...3225
: 2nd migration...3226
: last migration
Here second
is after first
in the alphabetical order, so it's it not a problem, but it could be with other namings.
We should also update the README with the new -b --block option added to down command. EDIT : sorry, actually there is no need to do that as there is the --help option |
any updates on this feature ? |
Hi Team, Regarding PR, Enable rollback of all scripts from same migration #331 when it can be commited to main branch Regards |
Any Update on this, We are looking for this feature |
Hi, @seppevs. this PR are so important for all of us. can you merge please? |
Any update on why this PR has not been merged yet? |
Hi, here is a possible implementation of
migrate-mongo down
command to enable rollback of several migration scripts of a same migration. When you process to migration you can rollback all migrations scripts from a same migration.If you have 3 pending migartions and you run
migrate-mongo up
,migrate-mongo down --block
command will rollback the three migration scripts.It could be usefull if you want to integrate it.
Thank you :)
Checklist
npm test
passes and has 100% coverage