Flyway 3.0 Migration Checksum mismatch
Flyway 3.0 changed the default of validateOnMigrate to true.
This is however a good thing, as in the spirit of fail fast, errors are discovered sooner.
In your case some scripts did change since they were applied, which is what Flyway is reporting.
You have two options:
- suppress the error by setting validateOnMigrate to false (2.3 default behavior)
- invoke
Flyway.repair()
to reallign the checksums
Reference
Flyway Repair
flyway - Validate failed: Detected failed migration to version 1
First of all, you should evaluate flyway repair
to tell the flyway that you have fixed the issue and then run flyway migrate
.
Spring Boot 1.5 to 2 migration - Flyway migration checksum mismatch
It seems that the checksum algorithm has changed between versions.
In (some) versions of Flyway 4
,
all checksums are automatically recalculated and updated with the new algorithm on first run (Flyway #253)
I'm not sure if this means that the checksum is calculated with both versions, and if it matches the old version is updated with the new version, or if it means that it's blindly overwritten with the new one.
Flyway Checksum Algorithm:
version 3 - crc32 over bytes:
bytes = resource.loadAsBytes()
...
crc32.update(bytes);version 5 (not a verbatim copy) - crc32 over lines (ignoring CR/LF, and using UTF-8 encoding):
BufferedReader bufferedReader = new BufferedReader(new StringReader(resource.loadAsString(configuration.getEncoding())));
[...]
while ((line = bufferedReader.readLine()) != null) {
crc32.update(line.getBytes("UTF-8"));
}
Solution
In the answer to Flyway repair with Spring Boot multiple solutions are presented.
Because manual intervention had to be avoided, I've used the FlywayMigrationStrategy
and a jdbcTemplate
to update at startup the checksums from fixed known values to the new fixed know values required by Flyway 5.
Related Topics
Java:Using Apache Poi How to Convert Ms Word File to Pdf
Duplicate Entry Exception: Spring Hibernate/Jpa Cascade Save Many to One
Error Says It's Dividing by Zero While It's Not Initialised as Zero
Checking If a String Contains Only Digits (Isdigitmethod Required)
How to Mock a Generic Parameter for a Unit Test in Java
Selecting from Div Class Dropdown - Selenium
Maven Builds Are Working, But Junit Is Throwing a Nosuchmethoderror
Java.Lang.Noclassdeffounderror: Org/Springframework/Core/Env/Configurableenvironment
Java.Lang.Noclassdeffounderror: Lorg/Apache/Logging/Log4J/Logger; But the Artifact Exists
Correct Way to Focus an Element in Selenium Webdriver Using Java
In Firebase After Uploading Image How to Get Url
In Java, How to Determine If a Char Array Contains a Particular Character
How to Have Each Record of Json on a Separate Line
Keycloak - Create Realms/Users/Groups Programmatically