Prevent new ChangeSet before already applied ones

Hello.

I´m starting with Liquibase for a new project.

(I my past I already used some different DB maintenance tools.)

There is one thing which I didn´t find a solution for in Liquibase:

Say, I have a number of ChangeSets (e.g. defined in XML) already applied to the database. Than, there is a new ChangeSet defined in the XML but between already existing ChangeSets.

For better understanding:

  • ChangeSets applied to database: A, B, C

  • XML with ChangeSets is changed and new ChangeSets are: A, B, D, C

Applying ChangeSet D on the database despite having already A,B,C applied might be working fine. But if applied to a new database, D could fail because if relies on some structure created by C.

From my previous experience with DB maintain tools I expected to get an error because the order of the ChangeSets would now have changed. But that´s not the case; the change is just applied to the existing database.

Is there a way to tell Liquibase to check the order and fail if there are created new ChangeSets between already applied ones?

If not, how should we deal with such cases?

Of course, the CI pipeline would fail in this case. But personally I find it critical that the ChangeSet order is not checked by Liquibase itself. Or do I oversee something?

Hi,

Liquibase runs the changeset in the order you make in the changelog, from the documentation it says:

 As Liquibase executes the databaseChangeLog, it reads the changeSets in order and, for each one, checks the “databasechangelog” table to see if the combination of id/author/filepath has been run. If it has been run, the changeSet will be skipped unless there is a true “runAlways” tag. After all the changes in the changeSet are run, Liquibase will insert a new row with the id/author/filepath along with an MD5Sum of the changeSet (see below) in the “databasechangelog”.


The ordering is the user’s responsibility, the paridgm isn’t to check to see if there was a new add to the changelog.  The liquibase enterprise product (aka Datical) does sorta verify ordering but it has another commit order paradigm it follows.

HTH,

Ronak