Flag to compute checksums in changeSets with parameters before value substitution


If you have a change set like:

the checksum is based on the value in ${param}. Normally this is best, but there are times you only care that the insert checksum is the same irregardless of the param value


Change Sets with parameters


Nathan Voxland
March 16, 2016, 1:42 PM

No estimate on a 4.0 timeline, but it will be a while. Probably closer to late 2016.

For your case, would it work to just run "UPDATE DATABASECHANGELOG SET MD5SUM=NULL" as part of the load into QA? That will make liquibase rebuild the checksums for all the changeSets and it won't matter what they were in production.

Julien AUBIN
April 19, 2016, 7:48 AM


I suggest the following changes on branch 3.4.x which would fix the issue. If you think it is a good approach I perform the fix :

1/ In class ParsedNode add a clone() method which does a deep copy of the node tree. No need to perform a deep copy of other fields, a simple copy is enough as their content is not altered on cloned copies.

2/ In class ChangeSet, add a getter/setter on a field named ChecksumChangeSet which is basically a ChangeSet in which properties would not be substituted.

3/ In method DatabaseChangeNode.handleChildNode :
a/ At the very beginning, clone the parsedNode before expanding the values.
b/ in the if (nodeName.equals("changeSet")) call the setter on the checksumChangeSet field of ChangeSet, after having called for a second time the createChangeSet method. It means that the cold would become something like this :
if (nodeName.equals("changeSet")) {
ChangeSet cs = createChangeSet(node, resourceAccessor);
cs.setChecksumChangeSet(createChangeSet(nodeChecksum, resourceAccessor));

4/ In method ChangeSet.generateChecksum() add at the very beginning the following code :

if (checksumChangeSet != null) {
return checksumChangeSet.generateChecksum();

Do you think it would be sufficient to tackle the issue or not ?

Note : we could even put a per-changeset flag in order to avoid regressions. By default the new MD5 computation method would be disabled, but if in the yaml/xml/... it states that the MD5 calculation method must be switched then we perform the switch.


Julien AUBIN
May 14, 2016, 7:44 AM


Any suggestion about the proposed fix ?

Julien AUBIN
May 18, 2016, 9:45 AM

Just created pull request https://github.com/liquibase/liquibase/pull/578 with my changes. Currently I did not put a flag, but if you're ok with the changes I could do it. Please let me know in that case the flag name you'd wish to see. I'm thinking of something like "rawChecksum".

Nathan Voxland
May 18, 2016, 2:48 PM

Thanks, I'll take a look.


Nathan Voxland

Fix versions

Affects versions