migrate-mongo icon indicating copy to clipboard operation
migrate-mongo copied to clipboard

Automatic rollback support

Open Lolobstant opened this issue 4 years ago • 2 comments

Is your feature request related to a problem? Please describe. It would be great to have a way to run down operation automatically when a rollback occurs.

Describe the solution you'd like Maybe a way to bump a runtime version number in package.json when creating a migration file, and saving in the change log which runtime version the script was run? Then when a rollback occurs, all script with a runtime version over the current runtime are down.

It could actually be used to make up and down operations automatically with a simple run command for exemple, which would "just" have to run migration files under current runtime version and down migration files over it.

Describe alternatives you've considered

  • making a script to manage to bump a runtime version in package.json and saving in a collection which runtime version a script should run.
  • a documentation stating at which commit a migration as been created and running by hand down script when a rollback occurs

Additional context Add any other context or screenshots about the feature request here.

Lolobstant avatar Dec 09 '20 10:12 Lolobstant

Hello, I don't know if it's exactly what you mean, but had a similar issue, so I've implemented the rollback of a group of migration scripts and proposed it in a pull request. The code is here: https://github.com/seppevs/migrate-mongo/pull/331 If you have any feedback, or improvements, we can discuss :)

ftreguer avatar Mar 25 '21 15:03 ftreguer

I would propose maybe something similar here. When the command migration run for instance do the necessary up's & dows's based on the available migrations applied in the db and in the codebase. This Is useful when the app required to do a rollback to an older state where a migration down should be executed. The migration run should figure out that there is an extra migration in the database and it should be rollbacked (down).

YousefMMS avatar Apr 29 '21 15:04 YousefMMS