'Liquibase checksum validation error without any changes
Maven fires liquibase validation fail even no changes was made in changeset.
My database is oracle.
Situation:
In DB changelog table was record for changeset
<changeSet id="1" author="me" dbms="oracle">;Then by mistake i added another changeset
<changeSet id="1" author="me" dbms="hsqldb">Reruned liquibase scripts Maven fired checksum validation error.
Then i changed hsqldb changeSet to
<changeSet id="2" author="me" dbms="hsqldb">Maven still firing checksum validation error.
Then i changed first changeSet checksum in DB manually to current checkSum and scripts runned successfully.
Everything looks nice ,but when i redeploy whole application and run liquibase scripts checksum of first changeSet is still like before 6 step.
Solution 1:[1]
Everyone here is talking about how to fix this, but let me share a typical scenario where it may occur for you.
SHORT ANSWER : Change in line-separator due to one reason or another can cause checksum validation error and won't be visible in code changes.
Why did it occur for me? Please read below..
Suppose you have a tomcat server, and multiple people are involved in WAR deployment from time to time. Everyone uses INTELLIJ IDEA on LINUX but one of the team member switches to WINDOWS for some reason. Now, when the WINDOWS PERSON would create WAR, he may not notice that default line-separator selection in INTELLIJ IDEA for WINDOWS is CRLF but all previous builds built from LINUX machine which uses LF line-separator.
Change in line-separator affects all text files, which includes SQL files too. So you may have used following just like my team in your liquibase script
changeSet(author: "aditya", id: "1335831637231-1") {
sqlFile( path: "liquibase/quartz_oracle_tables.sql", "stripComments": true)
}
and the checksum of file would not match the one already stored in database throwing checksum validation error.
Solution 2:[2]
In my case I forgot that Liquibase writes all changelogs to database table.
Go to DATABASECHANGELOG table and remove manually your changelogs.
Solution 3:[3]
Liquibase reads databasechangelog table to validate recent changes.
So identify the databasechangelog id which is causing the problem and delete, as shown below:
select * from myschema.DATABASECHANGELOG;
Delete from myschema.DATABASECHANGELOG where ID='prob_id';
Solution 4:[4]
As I struggle with this one I want to make it easier for people with this same issue:
- Important!, liquibase has a liquibase has a changlog.xml file
- On the maven pom.xml place the following properties.
<project ...>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>*****</version>
<configuration>
<changeLogFile>src/main/resources/mychangelogfile.xml</changeLogFile>
<driver>oracle.jdbc.driver.OracleDriver</driver>
<url>jdbc:oracle:thin:@//X.X.X.X:PORT/XE</url>
<username>yourusername</username>
<password>password</password>
</configuration>
<executions>
<execution>
<goals>
<goal>clearCheckSums</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</project>
**** version the one I used 3.2.0 in url replace with proper IPADDRESS and PORT.
Finally you run mvn liquibase:clearCheckSums
Hope it helps!
Solution 5:[5]
Configure liquibase's database link information in the maven plugin.
like this:
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<configuration>
<changeLogFile>${project.basedir}/src/main/resources/config/liquibase/master.xml</changeLogFile>
<driver>com.mysql.cj.jdbc.Driver</driver>
<url>jdbc:mysql://localhost:3306/hos_gateway</url>
<username>root</username>
<password>root</password>
<referenceUrl>hibernate:spring:com.hos.physician.domain?dialect=org.hibernate.dialect.MySQL5InnoDBDialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy</referenceUrl>
<verbose>true</verbose>
<logging>debug</logging>
<contexts>!test</contexts>
</configuration>
</plugin>
Solution 6:[6]
Changeset id should not repeat. Give a new changeset id and try, it should work.
<changeSet id=
Solution 7:[7]
The liquibase documentation has a 2nd option now
The <validCheckSum> attribute
The second option is to add a <validCheckSum> element to the changeset. The text contents of the element should contain the old checksum from the error message.
Assuming you rarely have to change historic changelog XML files, then you rarely have error messages. If you get an error message then add a tag with the old checksum acknowledging it's fine.
Example:
<changeSet id="example" author="former-author" runOnChange="false">
<validCheckSum>8:869....4e3</validCheckSum>
<addColumn tableName="ye_olde_db_table">
<!-- fix some old typo or incompatibility, etc -->
</addColumn>
</changeSet>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Aditya T |
| Solution 2 | |
| Solution 3 | |
| Solution 4 | acabra85 |
| Solution 5 | zmag |
| Solution 6 | |
| Solution 7 | Steve Jones |
