【发布时间】:2018-07-25 07:08:16
【问题描述】:
我想在我的数据库中添加新值,并且我在此文档中看到了 http://www.liquibase.org/documentation/changes/load_update_data.html 已经有一个可能的解决方案但是一旦我创建了更改日志,只有一个插入正在执行,而不是重复键的更新。
我的数据库是 DERBY 10.12.1.1 和 Liquibase 3.5.1
这是我的变更集
<changeSet author="mva" id="changes">
<loadUpdateData encoding="UTF-8"
tableName="vi_prop_def"
primaryKey="pk_prop_def"
file="vi_prop_def-type.csv">
<column name="guid" type="STRING"/>
<column name="name" type="STRING"/>
<column name="description" type="STRING"/>
<column name="value_type" type="STRING"/>
<column name="property_order" type="NUMERIC"/>
<column name="group_guid" type="STRING"/>
<column name="required" type="NUMERIC"/>
<column name="is_collection" type="NUMERIC"/>
</loadUpdateData>
这是执行的语句
Reason: liquibase.exception.DatabaseException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'PK_PROP_DEF' defined on 'VI_PROP_DEF'. [Failed SQL: INSERT INTO APP.vi_prop_def (guid, name, description, value_type, property_order, group_guid, required, is_collection) VALUES ('b7ede117-4925-4e44-83ac-dfb10e8fc0f8', 'productionBeginDate', 'my production Date', 'DATE', 38, 'f2262f52-0cd9-4d69-ac19-dce871aa4a1e', 1, 0)]
确实已经插入了一个值,但我预计 liquibase 会生成一个插入,然后是对重复键的特定于 derby 的更新。
【问题讨论】: