Pre- and Post-migration scripts for Flyway

后端 未结 2 1117
轮回少年
轮回少年 2020-12-19 05:54

I am looking for a way to execute a hook script before and after migration. I have a bunch of views and stored procedures and would like the process to be:

  1. Dro
2条回答
  •  爱一瞬间的悲伤
    2020-12-19 06:14

    Update 2014-04-29: This is now Possible with Flyway 3.0 by implementing the FlywayCallback interface.

    Previous answer

    The short answer is: no, not at this point.

    Here is the reason: I thought about this as well as I was laying down the initial design for Flyway. The more I thought about this aspect though, the more it became clear to me that these pre and post scripts are also an integral part of the migration, or at least something a migration can not do without if it wants to be successful. Therefore I would recommend to either:

    • Merge 1, 2 & 3 in a single migration
    • Have 3 separate migrations x.1 (drop views), x.2 (actual migration), x.3 (rebuild views)

    You might even be able to have x.1 and x.3 call stored procedures that do the work for you to avoid code duplication between migrations if these steps are repeating.

    Having Flyway take care of performing all changes to the database structure makes the whole thing more straightforward, avoiding a mix of different technologies.

提交回复
热议问题