java flyway 3.1 迁移校验和不匹配。校验和的计算取决于平台

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29043269/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 14:35:09  来源:igfitidea点击:

flyway 3.1 Migration Checksum mismatch. Calculation of checksum is platform dependent

javalinuxdatabaseflyway

提问by Reza

I have a completely same project source and sql script in both windows and ubuntu client, development platform. when I compile and try to deploy the project on my linux server, I receive this exception only for my linux version package.

我在 windows 和 ubuntu 客户端、开发平台中都有一个完全相同的项目源和 sql 脚本。当我编译并尝试在我的 linux 服务器上部署项目时,我只收到我的 linux 版本包的这个异常。

Caused by: org.flywaydb.core.api.FlywayException: Validate failed. Found differences between applied migrations and available migrations: Migration Checksum mismatch for migration V2__xxx_module.sql: DB=-1434535307, Classpath=-282428834 at org.flywaydb.core.Flyway.doValidate(Flyway.java:1020) at org.flywaydb.core.Flyway.access$300(Flyway.java:52) at org.flywaydb.core.Flyway$1.execute(Flyway.java:925) at org.flywaydb.core.Flyway$1.execute(Flyway.java:919) at org.flywaydb.core.Flyway.execute(Flyway.java:1320) at org.flywaydb.core.Flyway.migrate(Flyway.java:919)

引起:org.flywaydb.core.api.FlywayException:验证失败。发现应用迁移和可用迁移之间的差异:迁移校验和不匹配 V2__xxx_module.sql: DB=-1434535307, Classpath=-282428834 at org.flywaydb.core.Flyway.doValidate(Flyway.java:1020) at org.flywaydb.core .Flyway.access$300(Flyway.java:52) 在 org.flywaydb.core.Flyway$1.execute(Flyway.java:925) 在 org.flywaydb.core.Flyway$1.execute(Flyway.java:919) 在 org .flywaydb.core.Flyway.execute(Flyway.java:1320) 在 org.flywaydb.core.Flyway.migrate(Flyway.java:919)

it seems there is platform dependency in version 3.1 too. I really need to work with both OS platform, so is there any way to fix that?

3.1 版似乎也存在平台依赖性。我真的需要同时使用两个操作系统平台,所以有什么办法可以解决这个问题吗?

Update :

更新 :

I saw that still many peoples have a same problem, so here is my way to fix the problem.

我看到仍然有很多人有同样的问题,所以这是我解决问题的方法。

I just turned off the validation and waiting for flyway 4 that they said that this problem is fixed there.

我刚刚关闭了验证并等待 Flyway 4,他们说这个问题在那里得到了解决。

Flyway flyway = new Flyway(); 
...
flyway.setValidateOnMigrate(false);

回答by Enno

This behaviour is fixed in Flyway 4.0. See https://github.com/flyway/flyway/issues/253

此行为已在 Flyway 4.0 中修复。见 https://github.com/flyway/flyway/issues/253

回答by Axel Fontaine

This is a known issue with Git: https://github.com/flyway/flyway/issues/253

这是 Git 的一个已知问题:https: //github.com/flyway/flyway/issues/253

You can work around it by properly configuring CRLF handling in .gitattributesto have consistent line endings (LF) across all platforms by for example adding * text eol=lfand only adding exceptions for the binary formats.

您可以通过正确配置 CRLF 处理.gitattributes以在所有平台上具有一致的行尾 (LF) 来解决此问题,例如添加* text eol=lf和仅添加二进制格式的例外。

回答by amit kumar

You have 3 options:

您有 3 个选择:

  1. use flywayversion 4.0
  2. use maven Flyway.repair()
  3. Delete SQL file. Clean and rebuild. Create SQL file again.
  1. 使用flyway4.0 版
  2. 使用 Maven Flyway.repair()
  3. 删除 SQL 文件。清洁和重建。再次创建 SQL 文件。