【问题标题】:How to rollback to a specific change set with Liquibase Command Line如何使用 Liquibase 命令行回滚到特定的更改集
【发布时间】:2018-05-10 22:08:07
【问题描述】:

我有两个 changeLog 文件(changeLog-1.0.1.xml、changeLog-2.0.1.xml)。 每个 changeLog 文件包含两个 changeSet(changeSet-1、changeSet-1) 两者都在应用部署时执行。

这就是我指定变更集的方式:

<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>

我想从命令行回滚第二个 changeLog 文件 (changeLog2.xml)。

我尝试了很多方法,但都没有成功。

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"

与 changeLog 文件位于同一目录时

更新:我成功地从命令行调用更新

    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

用于回滚

    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

通话崩溃

Unexpected error running Liquibase: rollback requires a rollback tag

【问题讨论】:

  • 您还可以按日期甚至按变更集数量回滚look here

标签: java spring postgresql maven liquibase


【解决方案1】:

我必须先创建一个标签

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

然后回滚到那个特定的标签

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-17
    相关资源
    最近更新 更多