Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Liquibase checksum validation error without any changes

Maven fires liquibase validation fail even no changes was made in changeset.

My database is oracle.

Situation:

  1. In DB changelog table was record for changeset <changeSet id="1" author="me" dbms="oracle">;

  2. Then by mistake i added another changeset <changeSet id="1" author="me" dbms="hsqldb">

  3. Reruned liquibase scripts Maven fired checksum validation error.

  4. Then i changed hsqldb changeSet to <changeSet id="2" author="me" dbms="hsqldb">

  5. Maven still firing checksum validation error.

  6. 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.

like image 910
Daggeto Avatar asked Apr 03 '12 14:04

Daggeto


People also ask

How do I remove checksum error in Liquibase?

Running the clear-checksums command To run the clear-checksums command, specify the database driver, classpath, and URL the Liquibase properties file. For more information, see Specifying Properties in a Connection Profile. You can also specify these properties in your command line.

How does Liquibase calculate checksum?

When running the calculate-checksum command, the DATABASECHANGELOG table calculates an MD5 checksum for each entry based on the SQL script of the changeset. This checksum helps Liquibase detect differences between the changesets you want to deploy and the changesets that have already been run against the database.

Where are Liquibase checksums?

In order to detect changes between what is currently in the changelog vs. what was actually run against the database, Liquibase stores a checksum with each changeset entry in the DATABASECHANGELOG tracking table.


2 Answers

If you're confident that your scripts correctly reflect what should be in the database, run the liquibase:clearCheckSums maven goal, which will clean it all up.

like image 98
Roy Truelove Avatar answered Nov 10 '22 18:11

Roy Truelove


Checksum validation errors are thrown by liquibase to indicate that the changes applied to the database no longer match the same content specified within the liquibase changeset files....

This is a safety measure designed to detect mis-behaving specification files and can easily happen during development. The best way to fix the problem is drop all objects and run liquibase against the development environment fresh as follows:

mvn liquibase:dropAll liquibase:update 

Warning - this will drop all objects in the schema. You will lose all data in tables, and any object not managed by Liquibase. Documentation for drop-all goal

Sometimes you actually want to support changing changesets. In those circumstances liquibase supports a "runOnChange" attribute which selectively applies the changesets against the database instance.

like image 40
Mark O'Connor Avatar answered Nov 10 '22 18:11

Mark O'Connor