Liquibase: Invocation of init method failed; nested exception is liquibase.exception.ValidationFailedException: Validation Failed:
In this blog post we will look at the troubleshooting issues encountered while using Liquibase database migrations and how to resolve them.
One of the issue you might encounter while working with Liquibase is validation failure related to checksum like below
Invocation of init method failed; nested exception is liquibase.exception.ValidationFailedException: Validation Failed:
1 change sets check sum
db/changelog/V1__Initail_Schema.sql::raw::includeAll was: 8:eb69c873e10dfca33439ef2690888cd9 but is now: 8:834d95ac0897a7565201ac62330421ec
Code language: Java (java)
Liquibase keeps track of applied changesets using checksum of the file.
If you change something in already applied changesets, it will modify the checksum of the file.
So Liquibase compares the checksum of already applied files and if they are not matching then it will throw Validation failure error.
To resolve the issue, you need to restore the changed file to previous state.
If you can restore previous state , you need to use the Liquibase CLI to clear and re-compute the checksums.
If you have installed Liquibase CLI, it has ‘clear-checksums
‘ command which clears all checksums and nullifies the MD5SUM column of the DATABASECHANGELOG table so they will be re-computed on the next database update.
changesets that have been deployed will have their checksums re-computed, and pending changesets will be deployed.
If you are applying the new changes in local dev environment and if you need to modify the script, then remove the entry from “databasechangelog” table and remove the database modifications manually and restart the application to apply the new changes.