Using multiple Preconditions with differen onFail-actions?

To workaround a problem with the creation of foreignkeys (see two posts below) we added a precondition to each foreignKey-create which just CONTINUES if the destination table is not present. (we have to run the update twice to do the work).

Now we ran into a problem with a createForeignKey for a column which was deleted meanwhile.

One possibility would be to add another precondition (which is actually not possible) which marks the changeset as ran:


Of course this would mean that we had to change the changeset when we drop the column, but this would be acceptable for us.

Another possibility would be to add something to the changeset dropiing the column which marks the now obsolete changeSet as ran (or ‘skipForever’), such as


the ‘markChangeSetRan’ would just mark the referenced changeSet (in the same file as we did not add a file-attribute) if it has not previously ran.

So when we execute the changelog to a fresh database where the changeset 1.1 did not run before changeset 8, the changeset 1.1 would just be skipped and marked as ran even it didn’t execute at all (as it is obsolete)

It’s tough, because you are working against liquibase’s design.  The normal operation is to append changes to the end of the changelog as you create tables, add foreign keys, drop columns, etc. so it expects everything to happen linearly.  I’m not sure exactly how your app works, but since you cannot go back and modify the original table definition as you add/remove columns keeping changes grouped by type usually doesn’t help and only adds confusion (like you are seeing)

The two precondition blocks is an interesting idea too.  It may be worth implementing in the future.  For now your markChangeSetRan option is probably the only one that will work for you.