I know that Liquibase reads xml files and verifies which changeset that has been run and which not. New changesets will then be applied to the current database.
But, what if I want to control that there are changesets recorded in the DATABASECHANGELOG table that have no counterpart in a changeset in an xml file. The scenario is that when you have different environments and you want a warning when the target database is in a when it cannot just be forwarded to a new state.
Both Environment 1 and 2 have starting points from an environment where changesets A and B existed.
Environment 1 has changesets A, B, C applied
Environment 2 has changesets A, B, D
If I try to run liquibase with Environment 2 changesets on the database (by mistake) that belongs to Environment 1 I would like to get a warning.
I know this is the other way around. Liquibase normally operates on xml-files and tries to match its content with DATABASECHANGELOG.
Best regards /Lasse
There is the changeSetRan precondition, if you know a given changeset that you want to make sure was not ran. You would have to know the author/id/path of the changeset, however.
If you don’t know the author/id/path, you could create a plugin precondition to check if any changesets defined in the database don’t exist in the changelog. The Precondition.check method is passed the databaseChangeLog object which you can use to get the defined id/author/paths. You could query the databasechangelog table and compare them.