Flyway使用Java类对SQL文件进行排序

huangapple 未分类评论48阅读模式
英文:

Flyway sort sql files with java class

问题

  1. 之前,我们添加了 V1__XX.sqlV2__YY.sqlV19_ZZ.sql 这些 SQL 文件,用于由 Flyway 应用。

  2. 然后我们引入了一个名为 V20_JJ.java 的 Java 迁移类。

  3. 现在,当我们添加 V21_NN.sql 时,我们会遇到 Detected resolved migration not applied to database 错误。

是否有可能按名称将 Java 和 SQL 迁移都按顺序放置?

(我们希望不使用 ignore missing migrationsout of order 特性,除非它们是最后的选择。)

英文:
  1. Previously, we added: V1__XX.sql, V2__YY.sql and V19_ZZ.sql sql files to be applied by Flyway.

  2. Then we introduced a Java migration class named: V20_JJ.java.

  3. Now, when we add V21_NN.sql, we get ofc Detected resolved migration not applied to database error.

Is it possible to put java and sql migrations all in order by name?

(We'd prefer not to use the ignore missing migrations or out of order features unless they are a last resort)

答案1

得分: 0

能解释一下为什么会出现错误吗?如果已经应用了迁移 V1V2... V20,那么在添加迁移 V21 时就不应该出错,因为它是按顺序的,并且没有被漏掉。

可能只是你的 V21_NN.sql 文件有问题。

英文:

Can you explain why do you get the error? In case you have migrations V1, V2... V20 already applied, you should not get error when adding migration V21 as it's in order and was not missed.

It may be just that your V21_NN.sql is incorrect.

huangapple
  • 本文由 发表于 2020年4月5日 00:07:35
  • 转载请务必保留本文链接:https://java.coder-hub.com/61030897.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定