- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
示例错误消息:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Validate failed: Migration checksum mismatch for migration version 0006.0
如何在不影响 flyway_schema_history 中的 flyway 脚本的情况下更改数据库表?
例如,我需要使用 alter 命令更改表名,但执行 flyway 迁移脚本没有失败。
任何建议,不胜感激。
注意:- 我不想从表 flyway_schema_history 中删除脚本条目。
最佳答案
有几种方法可以做到这一点:-
1) 创建一个具有增量版本的新脚本文件。将您的 DDL 命令放入此文件中以更改表。然后运行迁移。
2) 如果您不想从 schema_version 表中删除该条目,您可以更改该表中的校验和值。要计算校验和,请使用从 org.flywaydb.core.internal.resolver.sql.SqlMigrationResolver
复制的以下方法。您可以为资源参数传递 null
:-
/**
* Calculates the checksum of this string.
*
* @param str The string to calculate the checksum for.
* @return The crc-32 checksum of the bytes.
*/
/* private -> for testing */
static int calculateChecksum(Resource resource, String str) {
final CRC32 crc32 = new CRC32();
BufferedReader bufferedReader = new BufferedReader(new StringReader(str));
try {
String line;
while ((line = bufferedReader.readLine()) != null) {
crc32.update(line.getBytes("UTF-8"));
}
} catch (IOException e) {
String message = "Unable to calculate checksum";
if (resource != null) {
message += " for " + resource.getLocation() + " (" + resource.getLocationOnDisk() + ")";
}
throw new FlywayException(message, e);
}
return (int) crc32.getValue();
}
3) 如果您使用的是 Flyway Pro 版本 5+,则可以回滚迁移 https://flywaydb.org/getstarted/undo .
The answers here已经过时,但仍然可以为您提供帮助。
关于postgresql - Flyway - Flyway 架构迁移失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51760052/
是 Flyway适合在支持多个数据库的应用程序中实现吗? 我们不知道我们的客户在使用什么——可能是 MySQL、Postgres 或 Oracle。我们还可以使用 Flyway 为新版本的应用程序迁移
只想知道正在使用 flyway 的人是否得到了这个 > 版本设置为 0。 它突然开始出现在我的元数据表上,我不确定它从哪里来,也不知道如何运行 mugrates 而不会再次出现 最佳答案 这意味着 f
大家好! :) 我一直在看 Flyway,但我不确定如何使用它。就我而言,我有一个实体模型(使用 JPA 进行注释),对我而言,每次调用“迁移”并生成迁移文件时,FlyWay 都可以找出模型上的更改,
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 4 年前。 Improve this ques
场景:我有两个数据库。 第一个数据库是用于测试的空白数据库。我基本上运行 flyway:migrate 并使用完整的模式构建数据库,然后针对该空白数据库运行我的集成测试。在运行测试之前插入集成测试所需
我刚刚遇到了以下情况: 测试服务器当前正在运行 Flyway,版本为 1 (V1)。每当在 develop 分支上推送任何内容时,测试服务器都会自动更新(包括 Flyway 脚本)。 开发人员决定开始
我有一个项目,其数据库由 Flyway 在严格验证模式下管理。 我的迁移文件如下所示: V1.0__init.sql V11.0__even_better.sql V2.0__update.sql V
我们从项目开始就没有使用过 Flyway。我们处于先进的发展状态。专家评审建议在我们的项目中使用 Flyway。 问题是我们也将部分服务(微服务)移到了另一个测试环境中。 正确实现 Flyway 的最
我正在评估在我的项目中使用的 Flyway。我们当前的 SQL 脚本包含诸如 URL 之类的占位符,这些占位符将根据环境(dev、qa、prod)具有不同的域名。 具体来说,我们可能有 INSERT
我有一个名为V1_7__a_and_c.sql的flyway迁移脚本,但我意识到它不是关于“a”和“c”,而是关于“a”和“b”,所以该文件的正确名称实际上是 V1_7__a_and_b.sql。 我
我已将产品交付给客户。现在我已经升级了产品,其中包括对数据库的更改。 客户想要升级产品。现在 Flyway 将帮助客户数据从旧版本迁移到新版本。如果这是一个有效的用例,请告诉我。 flyway 文档仅
flyway 是否支持每个环境有条件地执行脚本? 例如,如果我有测试数据,是否可以创建一个仅在 env 配置为测试时加载的测试数据脚本文件夹? 最佳答案 对于 future 的访问者,这是针对特定于数
如果 flyway 在运行时最终会执行任何迁移,我们的部署系统想知道,因为它需要执行一组不同于没有数据库迁移的操作(如果有迁移,那么集群中的所有服务器都被关闭,然后一台服务器启动并执行迁移,然后将其余
我遇到以下问题: org.flywaydb.core.api.FlywayException: Validate failed: Detected applied migration not reso
我一直在阅读一篇关于 Flyway 的博客文章,名为 Lessons Learned Using Flyway DB with Distributed Version Control .作者的建议之一
因此,由于某些要求,我在升级 flyway 版本后了解到,flyway-core-2.2 为 Flyway 占位符引入了一些验证。 现在,占位符语法的约定在大多数库中都是 ${name} 统一的。在我
因此,只是探索使用 flyway 使用 Athena 提供的 JDBC 驱动程序针对 Amazon Athena 维护我的 DDL 语句的可能性,Athena 仅支持 CREATE 语句(hive D
我已经成功配置了 spring boot 和一个可以工作的新项目带飞路 使用 Postgres 数据库从 0001.0 版本迁移到 0008.0 我已经在本地手动更改了脚本但是flyway 迁移失败。
我目前正在使用 Flyway 命令行工具来管理我们的脚本,这些脚本将通过我们的 CI 构建服务器触发的发布过程来调用。 问题是我有 274 个可重复的迁移,涵盖包规范、包主体、函数、过程、 View
在 Flyway 中,我无法使用定义精确有序的迁移脚本集的文件(类似于 Liquibase approach )。 除了实现我自己的 MigrationResolver 之外,还有其他方法吗? 最佳答
我是一名优秀的程序员,十分优秀!