Search code examples
javaspring-bootliquibasehsqldb

Dynamic placeholder configuration in liquibase generated dynamic checksums


I am using spring, liquibase with hsql database. I am creating a sequence for a table, let's say example table. The sequence will be created from the liquibase like the following

<changeSet id="xx" author="yy" dbms="hsql">
<preConditions onFail="MARK_RAN">
<not>
<sequenceExists sequenceName="example_id_sequence"/>
</not>
</preConditions>
<createSequence sequenceName="example_id_sequence" startValue="${hsql.exampleSequenceCount}" incrementBy="1"/>
</changeSet> 

As you notice here, the startValue for the sequence is got from a external java code using changelog parameters of liquibase bean.

The first startup works fine. After inserting some data into the example table, when I restart the startValue now will be max Id+1 value of the table, it is returned like that for a requirement.

so the check sum changes and error is thrown. I tried including pre conditions, that also did not work. Is there any workaround for this like

If there is a sequence present, don't check the checksum and don't create a new sequence


Solution

  • As a workaround try adding:

    <validCheckSum>your-check-sum</validCheckSum>

    or:

    <validCheckSum>ANY</validCheckSum>

    It should make checkSum for this changeSet constant (or non-unportant in case of ANY), so this changeSet will be executed only once.