How to specify tag values in Liquibase changelog/changeset XML?

449 Views Asked by At

I have a changelog file which contains multiple changesets like this:

<include file="changesets\ISSUE_1\changeset.xml" relativeToChangelogFile="true" />
<include file="changesets\ISSUE_2\changeset.xml" relativeToChangelogFile="true" />
..
..

I want to tag each changeset with some values for example: ISSUE_1 after execution of 1st changeset and same for all the other changesets.

Instead of executing one changeset and then running the liquibase tag command and then running the second changeset I want to specify the tag value somewhere in the changelog/changeset xml itself.

And, I don't want a separate entry in the DATABASECHANGELOG table which the <tagDatabase> command provides.

Have tried something like this mentioning in the changeset file:

<changeSet id="ISSUE_1" author="SYSTEM" 
    failOnError="true" 
    dbms="oracle" 
    ext:tags="ISSUE_1" 
    ext:labels="RELEASE1">

But this modifies the label value in the DATABASECHANGELOG table but the tag value does not gets populated.

Please give a possible solution/way where to specify the tag value.

1

There are 1 best solutions below

0
On

Currently Liquibase doesn't have a way to do that. Like you saw, the two options it has is to either run the tag command after an update, which marks the last ran changeset OR use <changeSet... ><tagDatabase></changeSet> in your changelog which is part of another changeSet which is the one that gets tagged.

That said, Liquibase is very extensible if you're up for some Java coding. The Liquibase "contribute" site gives information on extension points. In this case, you might be able to pull off your logic by creating an extension that subclasses liquibase.sqlgenerator.core.MarkChangeSetRanGenerator.

Alternately, I could see it as being a nice alternative to the <tagDatabase> command and you could make the change as a pull request to the main project as well.