Options

Handling flyway migration failure

We have Flyway integrated to Bitbucket pipeline to deploy sql files in Snowflake database. It works like a breeze for best case scenario. When in bad scenarios, let's say there are 5 files added to code repository to be deployed, during migration
if first two in the sequence goes through fine and the third has a syntax error( code reviewed but uncaught error)
1. how can i make flyway fail just that file and let it continue to deploy rest of the files
2. Or how to handle this failure the easiest and elegant way. Righ now, we delete the entry in meta data table, repair the metadata, fix the file in code repo and re run the pipeline.

Appreciate your assistance.

Thanks

Answers

  • Options
    Normally I'd expect everything to be wrapped in a transaction and so the failure would cause the entire set of migrations to be unwound and Flyway's schema history table to be populated in a sensible way to allow you to retry when the problem is fixed (is this not happening ?).
    Otherwise you could look at using the target parameter and set flyway to work on one migration (next) at a time, so you iterate over your migrations in the pipeline rather than let flyway do it. When something fails the previous migrations are OK, you fix the failing one and then can move on with the rest.
    It's possible that one of the later migrations in your set depends on something in the failed migration so you wouldn't want to just ignore the failure and carry on.

Leave a Comment

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