When to use flyway repair?

Hi Flyway team.
We have a jenkins script to deploy DDL changes to Postgres. 
On each build execution, it executes following flyway commands 

info
repair
migrate

I have been trying to convince my team that repair is the tool to be used only when there is an exceptional scenario. It should be NOT be run all the time. It can cause problems.
One problem is if a developer changes already applied migration, repair will fix the checksum and flyway migrate will succeed. Developer will think change is applied, but actually it isn't. Without repair, migrate would have failed, which is correct. 

Please provide guidelines on when to use repair and what are the repercussions of using it all the time. 
Tagged:

Best Answer

  • Peter_LawsPeter_Laws Posts: 277 Silver 2
    Hello virajb,

    Thank you for the question. Your understanding is indeed correct, it should be invoked as needed, not as a matter of course. There are multiple reasons for this.

    As you highlighted, the safety net of checksum changes, in the current configuration, someone could essentially make silent modifications and were this then later run against a new environment, you would have disparate results.

    Showing failed migrations is particularly desirable if you have multiple people contributing as it will highlight existing issues, making it easier to avoid compounding them.

    Lastly, something often missed is that repair is a targetted command just like migrate. So if the locations were to change in your pipeline for migrate alone, the unmodified repair command would then most likely not do what you were intending and on the next run, remove all the applied migration that it couldn't resolve.
    (source)

    The intention of repair should effectively be 'maintenance mode' in the event manual intervention is required.
    Kind regards
    Peter Laws | Redgate Software
    Have you visited our Help Center?

Answers

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file