Skip to content

ValidationFailedException after Liquibase update to 4.9.1

We were using older Liquibase that we now wanted to update to 4.9.1 due to vulnerabilities in older versions. However, now at least one of our old migrations fails with ValidationFailedException:

Invocation of init method failed; nested exception is liquibase.exception.ValidationFailedException: Validation Failed:
     1 changes have validation failures
          Postgresql requires constraintName on addPrimaryKey when clustered=true, config/liquibase/changelog/1580719313000-1.xml::1580719313000-1::xyz

The constraintName is missing from <addPrimaryKey>. However, it worked just fine with the older versions.

How can we fix this? If we change the migration, it changes its checksum and it will instead complain that there is a migration it doesn not know about.

Answer

You can update your changeset and add validCheckSum tag with the new value of the checksum. This way validation will pass, and changeset will still be deemed as executed on the existing databases. Check out the docs from Liquibase.