Hi,
I started to use Liquibase this year and after some initial work, I am already very happy with the outcome. For most of my scenarios I was able to find a solution. Unfortunately, I don’t have the Pro version available. I use SQL changelogs wherever possible, if not then YAML.
What still does not work is my rollback scenario, because I am having difficulties to maintain a “tag history” in my databasechangelog. My idea was to use one separate changelog file for tagging, with a version parameter that is set in my properties file and runOnChange and/or runAlways set to true. This changelog is the last entry in my changelog root. With this approach I would not need to tag in every update changelog.
My changelog-version.yaml looks like this:
databaseChangeLog:
- changeSet:
id: 1
author: asg
runOnChange: true
context: development,staging,production
changes:
- tagDatabase:
tag: ${targetVersion}
To my understanding this is basically one of the “Uses” suggested in the documentation: runAlways (“Using tagDatabase to tag the current state of your database”). But runOnChange or runAlways update the existing databasechangelog record. So after every deployment, the previous tag record in my databasechangelog is overwritten with the new tag. The result is (of course) that a rollback command does not run because historic tags are not available.
My questions are:
- Is there a scenario in which tagDatabase with runOnChange/runAlways makes sense, if you plan to use rollbacks?
- How are you (automatically) tagging your databases to be “rollback-ready”?
- The rollback command seems to be designed to remove also the tagged row from databasechangelog. How do you handle that?
In the past I also tested the tag command, but it does not create a new row in the databasechangelog. Instead it adds the tag to the last row. But rollback seemed to behave the same and happily removed the last changelog record. It seemed strange to me. I was not sure if this behaviour is intended and therefore I dropped this approach.
I am still a Liquibase beginner so I would be happy to hear about your experience in this regard.