0

Based on my understanding about flyway/liquibase, they provide ways to perform database upgrades through the pre configured scripts (SQL queries, Java files, etc.,). But i am not very much clear about the following :

  1. What happens if there is destructive upgrade.

    I have a use case like changing an bigint column(containing data) to date type. If i try to change it directly, i will end up with corrupted data for the column. How does flyway/liquibase handle these kinds of upgrades ?

  2. Whether pre configured scripts are the only way to say flyway/liquibase that these are my changes or is there any other way for that matter. If there is some other way, will it output the diff in the form of queries ?

It will be very much helpful if someone shed light on the above.

Sai
  • 13
  • 2

2 Answers2

0

In Liquibase you can make this work by using the SQL Formated scripts, I assume your trying to make use of the XML markup tags to avoid having to do raw SQL and running into the down fall of having the XML translate exactly what you want to do. Make life easier and use SQL scripts and leverage Liquibase.

Kuberchaun
  • 29,160
  • 7
  • 51
  • 59
0

Speaking from Flyway's perspective, it was built with sql and java support from the start. How you migrate your db using either of these is your responsibility. Flyway will do as you tell it.

Axel Fontaine
  • 34,542
  • 16
  • 106
  • 137
  • Axel, thanks. Based on your doc on java based migrations [here](http://flywaydb.org/documentation/migration/java.html), it seems i have to implement jdbcMigrations to handle destructive upgrades like the one i mention in my first question. In such cases how can i handle the dynamic(new) inserts/updates when the migration is in progress ? Is there any handling/configuration in flyway which i can use for this handling ? In short, whether flyway provides any kind of mechanism to handle destructive upgrades or its just a framework to execute the supplied queries on the configured schema/schemata. – Sai May 24 '13 at 15:55
  • There is no magic. It does what you tell it to do. In your case, you should probably do it in several steps along those lines: add a new column in the new format, migrate the data, change the code to the new format and column, drop the old column. – Axel Fontaine May 24 '13 at 16:36
  • Axel, that makes sense. So it is up to me how i handle the insert/update/delete operations that happens during the migration. And flyway doesn't has any handler/configuration to support the same, am i right ? – Sai May 24 '13 at 17:42