Handling flyway migration failure
Nandha
Posts: 1 New member
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
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
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.