Execution dependent on pending changes

We have a circumstance where we have a runAlways changeset, except it’s not really always, rather it should only run if there are other pending changes. Has anybody arrived at a solution for a similar problem? It occurs to me that if there is a runAlways anywhere in the hierarchy, pending changes would always be true making this either very hard or impossible.

We did consider a precondition with a custom sql statement but it would require setting a property within the sql (something along the lines of “select 1 where ${dothechangeset} = 1”) but I can only find documentation demonstrating properties in attributes. I was unable to get the sql precondition to work correctly but I can’t tell if it’s because the property isn’t set properly.

Sorry for the slow response.  Your question got buried at the bottom of my stack.

Usually what I do is create a precondition that checks the state of the database based on what you would expect based on what the other changets will do.  For example, if you have a later changeset that would create a table, you would do a precondition check.

Properties were only available in attributes in the 1.9 codebase.  As of the upcoming 2.0 release they can appear in text blocks as well.

I’m not sure off hand how you would check to see if there are any arbitrary pending changes.  If this is what you want, your best bet may be to try the 2.0 pre-release from http://liquibase.org/ci/latest and create your own precondition.  The changelog object is passed and you can call methods on there as needed to see what will run.  I’m not sure if it will be possible, but that’s all I can think of right now.  You can see what docs we have so far on custom preconditions from http://liquibase.org/extensions

Nathan