Problem with rollback strategy

Hi all, my first message here.

I’m not sure how to implement rollback in my cicd pipeline using liquibase.

I have my application code and liquibase changsets in my git repository. When we release a new version the CICD software deploys the new version of the application and executes the changesets in the appropriate environment. Executing the changesets consists of calling ‘update’ and then ‘tag’ with the new version number of the application, for example 1.2.

My problem occurs when a new version of the application only involves a code change and there is no new changeset to run. The CICD pipeline executes the ‘update’ and the ‘tag’ and overwrites the new tag in the DATABASECHANGELOG table (to 1.3 for example). These types of changes are common and the version number can be updated several times without new liquibase changesets. Let’s assume that we have updated to version 1.7.

If after this we want to rollback to version 1.2 liquibase will tell me that the label does not exist. I don’t know if I’m following the right approach. From my point of view, the ideal is that all the tags that are applied to the liquibase changesets will be preserved, even if there are no changes in the database.

Maybe there is a better way to do it but I don’t know.

Thanks in advance.

Running the “tag” command does write the tag label to the most recent row in the databasechangelog table, and it will override the existing tag label on that row, if one exists. Someone from liquibase will need to address whether that is the intended behavior or not.

I’d recommend using the “tagDatabase” change-type inside of your changelogs. This will insert a new row into the databasechangelog table, and not overwrite the most recent tag label.

<changeSet id="tag_database_v0.2" author="BOB">
  <tagDatabase tag="v0.2"/>

This change-type can be used in xml, yaml, or json changesets.

Hi daryldoak

Thank you very much for your suggestion. I didn’t know the “tagDatabase” command. I have to do some research and do some testing to see if it can be useful in my use case.
I will write soon with the results.
Thank you so much.

You’re Welcome.

Just to clarify, “tagDatabase” is not a Liquibase command, it’s a change-type.

You are right. I still don’t know some of the liquibase concepts well.

1 Like

No problem, just wanted to make sure it was clear.