如何强制Liquibase在不重新运行语句的情况下重新计算校验和? [英] How can I force Liquibase to recalculate checksums without re-running the statements?

查看:131
本文介绍了如何强制Liquibase在不重新运行语句的情况下重新计算校验和?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在Java 6中使用Liquibase 3.2.是否有一种方法可以强制Liquibase重新计算校验和,而无需从我们的Liquibase文件中重新运行相同的语句?在我们的数据库中,运行此...

We're using Liquibase 3.2 with Java 6. Is there a way I can force Liquibase to recalculate checksums without re-running the same statements from our Liquibase files? In our database, I run this ...

update DATABASECHANGELOG set md5sum = null where 1;

但是,当我运行Liquibase更改脚本时,某些执行仍然会失败,并出现以下错误...

However, when I run my Liquibase change scripts, certain executions still fail with the following errors ...

invoking liquibase change script with file /tmp/deploywork/db.changelog-master.xml
running /usr/java/liquibase/liquibase  --logLevel=info --driver=com.mysql.jdbc.Driver --classpath=/usr/java/jboss/modules/com/mysql/main/mysql-connector-java-5.1.22-bin.jar --changeLogFile=/tmp/deploywork/db.changelog-master.xml --url="jdbc:mysql://myservername:3306/my_db" --username=username --password=password update 
INFO 5/13/15 2:15 PM: liquibase: Successfully acquired change log lock
INFO 5/13/15 2:15 PM: liquibase: Reading from my_db.DATABASECHANGELOG
INFO 5/13/15 2:15 PM: liquibase: Successfully released change log lock
Unexpected error running Liquibase: Validation Failed:
     3 change sets check sum
          db.changelog-1.0.xml::1357593229391-25::rob (generated) is now: 7:5cfe9ecd779a71b6287ef2360a6979bf
          db.changelog-7.0.xml::create-address-email-index::davea is now: 7:da0132e30ebd6a1bc52d9a39bb8c56d7
          db.changelog-7.0.xml::add-myproject-event-object-id-col::davea is now: 7:2eab5d784647ce33ef3488aa8c383443


SEVERE 5/13/15 2:15 PM: liquibase: Validation Failed:
     3 change sets check sum
          db.changelog-1.0.xml::1357593229391-25::rob (generated) is now: 7:5cfe9ecd779a71b6287ef2360a6979bf
          db.changelog-7.0.xml::create-address-email-index::davea is now: 7:da0132e30ebd6a1bc52d9a39bb8c56d7
          db.changelog-7.0.xml::add-myproject-event-object-id-col::davea is now: 7:2eab5d784647ce33ef3488aa8c383443

liquibase.exception.ValidationFailedException: Validation Failed:
     3 change sets check sum
          db.changelog-1.0.xml::1357593229391-25::rob (generated) is now: 7:5cfe9ecd779a71b6287ef2360a6979bf
          db.changelog-7.0.xml::create-address-email-index::davea is now: 7:da0132e30ebd6a1bc52d9a39bb8c56d7
          db.changelog-7.0.xml::add-myproject-event-object-id-col::davea is now: 7:2eab5d784647ce33ef3488aa8c383443

    at liquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:181)
    at liquibase.Liquibase.update(Liquibase.java:191)
    at liquibase.Liquibase.update(Liquibase.java:174)
    at liquibase.integration.commandline.Main.doMigration(Main.java:997)
    at liquibase.integration.commandline.Main.run(Main.java:170)
    at liquibase.integration.commandline.Main.main(Main.java:89)

这是脚本抱怨的更改集之一……

Here is one of the change sets that the script is complaining about …

    <changeSet author="davea" id="add-myproject-event-object-id-col">
        <addColumn tableName="sb_myproject_event">
            <column name="OBJECT_ID" type="VARCHAR(32)"/>
        </addColumn>
        <createIndex indexName="SB_myproject_EVENT_IDX"
            tableName="sb_myproject_event"
            unique="false">
            <column name="OBJECT_ID" type="varchar(32)" />
        </createIndex>
        <sql>update sb_myproject_event set object_id=LEFT(SUBSTRING_INDEX(event_data, '&quot;id&quot;:&quot;', -2), 24) where object_id is null and event_data is not null;</sql>
        <!--  Delete older events that no longer need to be processed -->
        <sql>delete from sb_myproject_event where id not in (select q.* from (select e.id FROM sb_myproject_event e, (select object_id, max(date_processed) d from sb_myproject_event group by object_id) o where e.object_id = o.object_id and e.date_processed = o.d) q);</sql>
    </changeSet>

正如我所说,我只想重新计算校验和(必须这样做,因为我们正在更改Liquibase版本).

As I said, I only want to recalculate checksums (have to do this because we're changing Liquibase versions).

推荐答案

与其使用SQL清除校验和,不如让Liquibase使用clearCheckSums命令来做到这一点可能更好:

Rather than clearing the checksums yourself using SQL, it will probably be better to let Liquibase do that by using the clearCheckSums command:

http://www.liquibase.org/documentation/command_line.html

从数据库中删除当前的校验和.在下一次运行时,将重新计算校验和.

这篇关于如何强制Liquibase在不重新运行语句的情况下重新计算校验和?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆