Search code examples
flyway

How to reapply failed sql Scripts with Flyway


I am trying flyway for first time, evaluating how it will fit into our project. Trying to understand how a Failed Scenario will work

enter image description here

Naturally, what i did next was, modified the sql script, and re tried running, but got checksum error enter image description here

Have three Ques here

  1. So I guess the only way out is ... need to make a 1.2 with correct format or manually modify 'schema_version' table. Right , or am i missing something?
  2. Wondering how will such a scenario work in case if this script is called from continuous integration tools (Jenkins or Bamboo). Manual Intervention will be needed.
  3. Not sure if some other tool like Liquibase will behave in a different (better) manner

Solution

  • In that situation I think you should use "flyway repair" rather the "flyway migrate"

    https://flywaydb.org/documentation/command/repair

    One thing from your post that is not clear is was the script you ran a single DDL statement or a number of statements, of which one or more failed?. The reason for asking is that flyway records the results of a migration, but does not itself clean up 'script errors'. Depending on the database you are using this could be done by running the DDL statements within a transaction.

    Liquibased operates with a much tighter connection to the database as it directly interacts with the DDL that can be expressed in a range of different formats. As such it has a much tighter control over the management of DDL deployment.