Liquibase TAG best practice

Is it better to tag a version before making a change set or after making a change set? I need the tag for database rollback in the future.

I would appreciate any feedback.

2 Likes

I would suggest tagging after each “release” of your application. That will get you a known “checkpoint” that you can rollback to. Example pattern:

changeset1
changeset2
tag v1
changeset3
tag v1.1
changeset4
changeset5
changeset6
tag v2

This allows me to completely remove each release, if needed.

v1 represents changesets 1 and 2
v1.1 represents changeset 3
v2 represents changesets 4, 5, and 6

2 Likes

Thanks for your reply @daryldoak! I did a little rollback test according to your suggestion, and I found that if I rollback to tag v1.1, the tag v1.1 will be removed. If I want a complete release , do I have to tag v1.1 back to the database again every time after the rollback?

changeset1
changeset2
tag v1
changeset3

If you use the tagDatabase change-type in your changelogs, as opposed to the Liquibase “tag” command, then it will get reapplied automatically the next time you run Liquibase “update”.

<changeSet id="tag_database_v1" author="X">
  <tagDatabase tag="v1"/>
</changeSet>
1 Like