How can we help you today? How can we help you today?

How to use existence check in flyway migration script in enterprise edition (automate)

Hi developers,

I used the new Flyway Enterprise credentials, but I am still facing one issue.

Below is my script:

(used it in spring boot gradle)

I added the new credentials to my flyway.conf file. When I ran the migration, it threw an SQL syntax error, which is fine. However, the entire migration was marked as failed, but the first DROP COLUMN name statement was still executed, and the column was dropped from my table.

After fixing the syntax error in the second statement, I reran the migration, but it showed that there were failed migrations. I then used the repair command to clear the failed state and ran the migration again. This time, it threw an error saying, "No column/key found for the column 'name'" because the column had already been dropped.

It seems there’s no existence check happening here. I need a solution from your end for this issue. Additionally, I would like guidance on handling similar scenarios withADD COLUMNSCREATE TABLES and other migration operations.

 

Thanks.
 

ram kumar
0

Comments

1 comment

  • Christian Perez
    Official comment

    Hello Ram Kumar,
     
    Thanks for reaching out to Redgate Support, sorry to hear you got stuck with your Flyway project. In this case, could you let me know what kind of Database you are working with? I ask as some Database types should automatically rollback any changes performed mid migration when a migration fails, however other still do not. 
     
    In either case, when the migration initially failed, you may have had to run the undo migration to reintroduce the name column which was dropped. (assuming you have undo migrations being generated)
     
    Once the repair was run, the flyway_schema_history table no longer knows about the failed migration and then the subsequent migration fails as you said.
     
    Best Regards,
     
    Christian Perez
    Product Support Engineer

    Christian Perez

Add comment

Please sign in to leave a comment.