Liquibase programmatically instance without changelog file


I’m unable to create Liquibase instance (in my Java code) without providing changelog file. I need it for rollback only, so I think, only database connection should be needed. Is it possible?

Hello. I’m not sure I fully understand the questions, but I’ll provide a couple of tips:

  1. Liquibase can only be used to rollback sql that was deployed via Liquibase update, meaning it has been recorded in the databasechangelog tracking table.
  2. A changelog is required for Liquibase update and rollback.

Ok, I was sure, that changelog file is required only for update. I wonder what the changedlog file is required for during the rollback. All the required information are already in the liquibase table, so in my opinion the tag should be sufficient.

The changelog is required for rollback because Liquibase uses the changelog file, in addition to the databasechangelog table, to determine the rollback steps.

Thanks for clarification. I was thinking, that all required data is stored in Liquibase table and only tag is necessary to rollback

While tag is needed to know what state(tag,date,count) to rollback to, the actual rollback depends on metadata table (author,id,path) and what’s written inside the changelog file for rollback.

Example, for XML formatted, liquibase knows the rollback of <createTable> tag, but for SQL formatted, it will run whatever you write after

A good way to know is to run rollbackSQL command, which will give you SQL on stdout.

And you will notice —changelogfile is a mandatory parameter for both update and rollback commands. Hope now you understand why. :+1: