Open Lolobstant opened 3 years ago
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 :)
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).
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 aredown
.It could actually be used to make
up
anddown
operations automatically with a simplerun
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
package.json
and saving in a collection which runtime version a script should run.down
script when a rollback occursAdditional context Add any other context or screenshots about the feature request here.