Reputation: 4076
I have a two changeLog files (changeLog-1.0.1.xml, changeLog-2.0.1.xml). Each changeLog file contains two changeSets (changeSet-1, changeSet-1) Both are being executed at app deploy time.
This is how I specify the changeSets:
<changeSet id="changeSet-1" author="someUser" labels="labelOne">
<createTable tableName="testTable" schemaName="public">
<column autoIncrement="true" name="id" type="BIGINT">
<constraints primaryKey="true"/>
</column>
</createTable>
<rollback>
<dropTable tableName="testTable"/>
</rollback>
</changeSet>
I want to rollback the second changeLog file (changeLog2.xml) from command line.
I tried a lot of ways, but did not succeed.
java -jar C:\..\.m2\repository\org\liquibase\liquibase-core\3.5.3\liquibase-core-3.5.3.jar update rollback changeSet-1 --changeLogFile="changeLog-1.0.1.xml"
when being in the same dir as changeLog file
update: I managed to successfully call update from command line
java -jar C:\Users\someUser\.m2\repository\org\liquibase\liquibase-core\3.5.3\liquibase-core-3.5.3.jar
--changeLogFile=changeLog.xml
--labels=labelOne
--url=jdbc:postgresql://localhost:5432/app2db
--classpath=C:/postgresql-42.1.4.jar
--username=app2user
--password=password
update
and for rollback
java -jar C:\Users\someUser\.m2\repository\org\liquibase\liquibase-core\3.5.3\liquibase-core-3.5.3.jar
--changeLogFile=changeLog.xml
--labels=labelOne
--url=jdbc:postgresql://localhost:5432/app2db
--classpath=C:/postgresql-42.1.4.jar
--username=app2user
--password=password
rollback
the call crashes with
Unexpected error running Liquibase: rollback requires a rollback tag
Upvotes: 3
Views: 7526
Reputation: 4076
I had to create a tag first
java -jar C:\path\.m2\repository\org\liquibase\liquibase-core\3.5.3\liquibase-core-3.5.3.jar
--changeLogFile=changeLog.xml
--url=jdbc:postgresql://localhost:5432/app2db
--classpath=C:/postgresql-42.1.4.jar
--username=app2user
--password=password
tag exampletag
then do the rollback to that specific tag
java -jar C:\path\.m2\repository\org\liquibase\liquibase-core\3.5.3\liquibase-core-3.5.3.jar
--changeLogFile=changeLog.xml
--labels=labelOne
--url=jdbc:postgresql://localhost:5432/app2db
--classpath=C:/postgresql-42.1.4.jar
--username=app2user
--password=password
rollback exampletag
Upvotes: 2