Reputation: 9
just use flywaytest to test my application. I would like to know if there is a method that, after importing a migration script, I make the rollback. If I was not clear, just ask information.
thanks
Upvotes: 0
Views: 13134
Reputation: 35169
This is explained in the FAQ:
Update: Flyway 5.0 now comes with an undo command.
Upvotes: 0
Reputation: 332
The flywaydb not support rollback in case of problems during migration the best you can user is:
http://flywaydb.org/documentation/maven/repair.html
But you will have to ensure for yourself the integrity of the data within the database.
If the database you're working to support checkpoints, always advise that before migrating, do the checkpoint.
good luck
Upvotes: 1
Reputation: 763
the flyway does not support rollback with one-line command,
there's no command like mvn flyway:rollback
, there are 2 ways you can do (IMO)
Upvotes: 0
Reputation: 488
Your question is not very clear but if you would like to rollback a failed migration and retry here are the steps you need to take:
If you look in your schema_version table you should see the script which failed (state column = FAILED). You need to correct this script so it doesn't fail again. Also if some of the script completed successfully you may have to manually revert these changes as running them again may cause a failure.
You then delete this row from the table
e.g. delete from schema_version where state = 'FAILED';
Then set the current version back to the script before the one that failed. You do this by setting it's CURRENT_VERSION to 1
e.g. update schema_version set current_version = 1 where version = 1.XX;
You can then attempt to run the flyway migration again.
Upvotes: 5