Search code examples
javamavenliquibasechecksum

How to solve liquibase checksum validation fail after liquibase upgrade


In my project I just tried upgrading liquibase from 3.2.2 to 3.4.2 (both the jars and the maven plugin). EDIT: same for upgrade to 3.3.x. As a consequence, starting the application now gives the following error:

Caused by: liquibase.exception.ValidationFailedException: Validation Failed:
   4 change sets check sum
   src/main/resources/changelogs/xxx_add_indices_to_event_tables.xml::xxx-add_indices_to_event_tables::xxx is now: 7:0fc8f1faf484a59a96125f3e63431128

This for 4 changesets out of 50, all of which add indexes, such as:

<createIndex indexName="idx_eventtype" tableName="events">
    <column name="eventtype" type="varchar(64)"/>
</createIndex>

While I can fix this locally, this would be a huge pain to manually fix on all running environments. Is this a bug, or is there some workaround?


Solution

  • You could also use the <validCheckSum> sub-tag of the <changeSet> to add the new checksums as valid checksums.

    Also, checkout the comments on the bug CORE-1950. You could put the log level to "debug" on both of your liquibase versions and see if you can find differences in the log output of the checksum creations.

    Use subtag something like this

    <changeSet id="00000000000009" author="system">
        <validCheckSum>7:19f99d93fcb9909c7749b7fc2dce1417</validCheckSum>
        <preConditions onFail="MARK_RAN">
            <sqlCheck expectedResult="0">SELECT COUNT(*) FROM users</sqlCheck>
        </preConditions>
        <loadData encoding="UTF-8" file="users.csv" separator=";" tableName="users">
            <column name="active" type="boolean" />
            <column name="deleted" type="boolean" />
        </loadData>
    </changeSet>
    

    You should remember that the value of the validCheckSum tag is the new checksum for the changeset.