使用Flyway时的升级方案 [英] Upgrade scenario when using Flyway

查看:288
本文介绍了使用Flyway时的升级方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只需将Flyway集成到我们的应用中,它就可以在以下情况下很好地发挥作用:

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

  • 带有空模式的全新应用程序安装,创建schema_version表并执行完整的模式脚本,然后该应用程序就可以运行了..效果很好!

  • 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!

具有补丁程序sql脚本,我们将版本设置为高于当前版本,补丁程序将自动应用,版本递增,此处没有问题!

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!

现在问题如下: 我们在那里有较旧版本的应用程序.假设我们当前的应用程序版本是7.5(模式版本1.0),当用户使用7.4的应用程序(我们将模式版本手动设置为0.9)并升级到7.5时,应使用对于空数据库,升级脚本而不是完整脚本.有道理?我该如何处理这种情况,Flyway似乎没有涵盖它.

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:

我们的应用v7.5的全新安装: -安装新架构v1.0使用MX_1_0__complete.sql

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

将应用程序从v7.4升级到v7.5: -将架构从v0.9升级到v1.0时,应使用MX_1_0__74upgrade.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

由于两个目标架构版本均为1.0,因此Flyway如何选择一个?另外,根据现有版本号,只能执行升级或完整脚本,不能同时执行!!如果当前版本为0.9,则选择升级脚本;如果当前版本为1.0,则不执行任何操作;如果没有当前版本,则将应用完整的1.0脚本来创建新架构.

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.

应该足够简单...

推荐答案

始终运行所有脚本.

  • 全新安装的v7.4:运行0.9脚本.
  • 全新安装的v7.5:运行0.9脚本和1.0升级.
  • 将v7.4升级到v7.5 ...:运行1.0升级.

这篇关于使用Flyway时的升级方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆