Liquibase Rollback

Hi,

I have just started to look at liquibase. I am trying to understand

how to do a rollback. I simply created three very simply changes

file: changelogs/change1.sql

–liquibase formatted sql

–changeset cky:1

alter table user add test1 text;

–rollback alter table user drop column test1;

file: changelogs/change2.sql

–liquibase formatted sql

–changeset cky:2

-alter table user add test2 text;

–rollback alter table user drop column test2;

file: changelogs/change2.sql

–liquibase formatted sql

–changeset cky:3

-alter table user add test3 text;

–rollback alter table user drop column test3;

So as above, each of the changesets add a column called test[x] and

then their respective rollbacks drop them.

I actually have each of these changesets in a separate file.

I am trying to understand how the rollback works.

I have applied all the three sets using

./liquibase --classpath=mysql-connector-java-5.1.35-bin.jar --driver=com.mysql.jdbc.Driver --changeLogFile=changelogs/change1.sql --url=“jdbc:mysql://mysql-staging/affiliate” --username=user --password=pass migrate

The DATABASECHANGELOG table contains all 3 changes.

I also tag each of the changes as tag1, tag2 and tag3 respectively.

./liquibase --classpath=mysql-connector-java-5.1.35-bin.jar --driver=com.mysql.jdbc.Driver --changeLogFile=changelogs/change1.sql --url=“jdbc:mysql://mysql-staging/affiliate” --username=user --password=pass tag tag1

Now, to rollback to tag1, I do

./liquibase --classpath=mysql-connector-java-5.1.35-bin.jar --driver=com.mysql.jdbc.Driver --changeLogFile=changelogs/change1.sql --url=“jdbc:mysql://mysql-staging/affiliate” --username=user --password=pass rollbackSQL tag1

But there is no ‘drop’ sql generated. I was expecting test2

and test3 columns to be deleted.

However, When I rollback using

./liquibase --classpath=mysql-connector-java-5.1.35-bin.jar --driver=com.mysql.jdbc.Driver --changeLogFile=changelogs/change2.sql --url=“jdbc:mysql://mysql-staging/affiliate” --username=user --password=pass rollbackSQL tag1, it does seem to generate a drop statement ‘alter table user drop column test2;’ but as you can see, it is only for column test2 but not for test2 and test3 both.

I tried rolling back using

/liquibase --classpath=mysql-connector-java-5.1.35-bin.jar --driver=com.mysql.jdbc.Driver --changeLogFile=changelogs/change3.sql --url=“jdbc:mysql://mysql-staging/affiliate” --username=user --password=pass rollbackSQL tag1, Here it seems to generate a drop statement ‘alter table user drop column test3’ for test3 but not test2.

I am failing to understand what is the purpose of the tag1 then ? It looks like it is picking up rollback statements from the changeLogFile that I specificy and not rolling back everything upto the tag automatically ?

PS: Liquibase version liquibase-3.3.4