Liquibase 3.2とJava 6.を使用しています。Liquibaseファイルから同じステートメントを再実行せずにLiquibaseにチェックサムを再計算させる方法はありますか?私たちのデータベースでは、これを実行します...
update DATABASECHANGELOG set md5sum = null where 1;
ただし、Liquibase変更スクリプトを実行すると、特定の実行が次のエラーで失敗します...
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)
スクリプトが文句を言っている変更セットの1つを次に示します。
<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, '"id":"', -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のバージョンを変更するため、これを行う必要があります)。
SQLを使用して自分でチェックサムをクリアするよりも、おそらくclearCheckSums
コマンドを使用してLiquibaseにそれを行わせる方がよいでしょう。
http://www.liquibase.org/documentation/command_line.html
データベースから現在のチェックサムを削除します。次回の実行時にチェックサムが再計算されます。