flyway

Retry a flyway failed migration


I'm just in the process of configuring and fully understanding Flyway, and I came into this situation:

However, once I made the necessary changes to the corresponding script to work, Flyway kept showing this message:

 Current schema version: 1.0.4
 com.googlecode.flyway.core.migration.MigrationException: Migration to version 1.0.4 failed! Please restore backups and roll back the database and codeflyway!

Since I didn't want to restore a complete dump and apply every migration again, just to make an alter table script to work, what I finally did was some changes to the 'schema_version' table:

After this, the migration was finally applied, and a success message was shown; however, I´m not quite sure if this is the right approach to deal with this kind of situation. I'm not sure if it's right to modify the 'schema_version' table by myself, since I think it should only be modified by Flyway itself.

So, after explaining what happened to me, my question would be:

Is there a way to 'retry' applying a failed migration in Flyway, without modifying the 'schema_version' table by myself?

Any commands I'm not aware of to fulfill this task?


Solution

  • This is answered in the FAQ: https://documentation.red-gate.com/fd/repair-277578892.html

    The upcoming Flyway 2.0 will include the repair command. This code is already checked into SCM.

    Note: This only deals with Flyway's metadata table. You are still responsible for cleaning up any other effects of a failed migration.

    Update: Flyway 2.0 has now been released. You can grab it at http://flywaydb.org