CustomChange and CheckSum

I�m using a customChange that calls out to a java class to prepare some sql statements dynamically.  The first time I run it, I�ll get maybe 40 statements.  The second time it�s run, 0 statements should be generated because the changeSet has already been run.

However, I would have expected that the 2nd time I run � the changeSet would be skipped because the checksum would be the same.  But, because of the dynamic sql being returned from the customChange, I�m thinking that the changeSet checksum is calculated differently on each run?

So, question 1 � when is the changeSet checksum calculated?

Question 2 � how can I skip the changeSet the second time consistently?  I�ve tried to use preconditions but they don�t appear to take affect because the checksum appears to be calculated before the precondition runs?  Is that a true statement?

It shouldn’t run the second time at all because it should be marked as ran in the databasechangelog table according to the id/author/filename.  The checksums should only be used to compare what was ran the last time vs. now to see if someone changed the changeset and would expect it to exeucte differently now.

For customChange’s, the checksum should just be based off the XML, not what is returned by the class.

Nathan

Unfortunately, that isn’t what I’m seeing…

I’m running it consecutively on a brand new DB.  The first time, things run fine and populate without issue.  The second time, I receive a checkSum error.

The only thing possibly changing is the returning sql statements from the custom change.  And you’re saying that definitely would not affect the checkSum?

My custom change executes a delete statement.  So, not only does the custom change return statements, but it does one execution as well.

Would THAT affect the calculation of the checksum?

I would not expect it to.  I’m looking into it (http://liquibase.jira.com/browse/CORE-533).

The checksums are generated before your changeset is ran, so there should be now way that the return values or what the class does should affect the checksum.  I wonder if there was a bad toString() call in what is used to genereate the checksum.

Nathan

This is the call used to generate the Element object in 1.9 that is serialized to make the checksum:

        public Element createNode(Document currentChangeLogDOM) {         Element customElement = currentChangeLogDOM.createElement("custom");         customElement.setAttribute("class", className);

            for (String param : params) {
                Element paramElement = currentChangeLogDOM.createElement(“param”);
                paramElement.setAttribute(“name”, param);
                paramElement.setAttribute(“value”, paramValues.get(param));

                customElement.appendChild(paramElement);
            }

            return customElement;
        }

So the checksum generated depends only on the XML, not anything inside the change.  I’m not able to duplicate the problem you are seeing.  Would you be able to make a test case?

Nathan