[SOLVED] - Silently stopping Liquibase at mid-update

Is there any way I can cancel a Liquibase update after I started it?

I've a list with around 5000 changesets, and I need to prevent all changesets from a specific point forward, to not be executed if a specific condition occurs in one of those scripts.

Since putting in all of the existing scripts, and to all the new ones that will be created until the end of days, is not a doable approach, I was looking into an alternative and already tried the following:

  • Created a and throw an exception
  • Created an invalid statement
  • Added in the

All cases work, but they also throw thousands of log lines (that I can't have), because I need a silent stop.

If you know the number of changesets you have to apply, you could use the equivalent of command line’s action "updateCount " in whatever way your are using liquibase.

Or is there no way to break your changelog into much smaller pieces? If you have to stop changesets from executing starting at some point, then you should have a way to create much smaller changelogs (with eventually one big changelog composed with includes).

I already have lots of small changesets. Don't understand exactly your suggestion here.

I was speaking about breaking your big changelog into smaller changelogs (not changesets) and applying only the last ones.

Or is there no way to break your changelog into much smaller pieces? If

you have to stop changesets from executing starting at some

point, then you should have a way to create much smaller

changelogs (with eventually one big changelog composed with includes).

I already have lots of small changesets. Don’t understand exactly your suggestion here.

Your answers gave me an idea and since we are dynamically creating an include changelog file, for all the smaller changelogs, I simple iterate all the smaller changelog files until I reach the file from each things can be executed or not.
Then I execute a query to check for the specific condition, and if everything ran ok, I create another dynamic changelog file with the remaining changelogs.

If I understand correctly:

  1. You got your changesets in tiny changelog files.
  2. You include all these mini changelogs into an include changelog file generated dynamically at process start, which will include all the changesets created up to this day.
  3. You run the big file.

Is that it ?

In this case, can’t you save the last changeset applied by this method and start dynamic generation starting from this saved data ?

That’s what I’m doing.

I create two "include changelog

file".

One that runs all the “tiny changelog files” until the point where the next “tiny changelog files” merged into a "include changelog

file" may run or not, based on a specific condition.