user1990133
user1990133

Reputation: 9

Rollback script migration

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

Answers (4)

samarone
samarone

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

Zava
Zava

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)

  1. follow the answer from @user528827
  2. try to use the rails's migration :)

Upvotes: 0

ciaranodc
ciaranodc

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:

  1. 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.

  2. You then delete this row from the table
    e.g. delete from schema_version where state = 'FAILED';

  3. 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;

  4. You can then attempt to run the flyway migration again.

Upvotes: 5

Related Questions