Upgrade scenario when using Flyway

こ雲淡風輕ζ 提交于 2020-01-25 13:10:03

问题


Just integrated Flyway into our app and it works great in the following situations:

  • brand new app install with empty schema, creates the schema_version table and executes the complete schema script after which app is on it's way..works great!

  • have a patch sql script, we set the version higher than the current version, patch get's applied automatically, version is incremented, no issues here!

Now the problem is the following: We have older versions of our app out there. Say our current application version is 7.5 (schema version 1.0), when a user is using 7.4 of the application (we will manually set the schema version to say 0.9) and is upgraded to 7.5 the schema upgrade to v 1.0 should be migrated using an Upgrade script rather than the complete script for an empty database. Make sense? How can I approach this scenario, it does not seem to be covered by Flyway.

In summary we have these two scenarios:

Brand new install of our app v7.5: - installation of new schema v1.0 uses MX_1_0__complete.sql

Upgrade of app from v7.4 to v7.5: - upgrade of schema from v0.9 to v1.0 should use MX_1_0__74upgrade.sql

since both target schema versions are 1.0 how does Flyway choose one over the other? In addition either only an upgrade or a complete script is to be executed depending on the existing version#, not both!! If current version is 0.9 then upgrade script to be chosen, if current version is 1.0 then nothing is to be done, if there is no current version then the complete 1.0 script to be applied to create a new schema.

Should be simple enough...


回答1:


Always run all scripts.

  • Brand new install of v7.4: Run 0.9 script.
  • Brand new install of v7.5: Run 0.9 script and 1.0 upgrade.
  • Upgrade v7.4 to v7.5 ... : Run 1.0 upgrade.


来源:https://stackoverflow.com/questions/22544831/upgrade-scenario-when-using-flyway

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!