Liquibase : How to use <preconditions> with changeset having runAlways true?

In my project, we used voltdb as database and we used liquibase for managing version and etc. We wrote changesets in one file and for voltdb and we used RunAlways.xml file which contains below steps

  • drop a procedure
  • create a jar file for all procedures
  • create a procedure in which changes were done
  • create partition if needed

RunAlways.xml file ran after update of existing DB or for new DB also.

Let’s say my change set for any procedure is

<changeSet dbms="voltdb" author="foo" id="foo-1" runAlways="true">
        <sql>DROP PROCEDURE BAR</sql>
        <rollback/>
</changeSet> 

Now I changed the <sql> statement and and changed statement is look like this

<sql>DROP PROCEDURE BAR IF EXISTS</sql>

After chnaging this I got
Unable to update database. liquibase.exception.ValidationFailedException: Validation Failed: error.

As per one Liquibase blog if we reformat the <sql> tage then it will affect the checksum.

So that I add <validCheckSum>ANY<validCheckSum> tag before <sql> tag. Now when ever RunAlways.xml will run it will not check for checkSum and run always my chnageSet without any error.

Now my question is, Instead of <validCheckSum> tag rather I want to use <preconditions> tag then how should I implement this? I found in on Liquibase blog that we can handle using <preconditions> tag also.

Also there are other solutions as well like clearchecksums command and etc.

Prompt assistance will be highly appreciated.

Add runOnChange=“true” to the changeset. This will prevent a modification from causing the checksum error when using runalways=“true”.

1 Like

@daryldoak I’ll try this solution