Liquibase loadUpdateData csv重新运行

时间:2016-11-04 14:09:49

标签: sql liquibase

我正在运行带有loadUpdateData变更集的liquibase。我添加了runOnChange = true,我现在遇到的问题是重复键。我的印象是loadUpdateData会执行插入,并且还会检查是否重复然后更新?

目前我的liquibase文件与变更集看起来像这样。

    <changeSet id="123" author="ranbir">
    <loadUpdateData tableName="address" primaryKey="address_id" schemaName="public" file="address.csv">
        <column name="address_id" type="NUMERIC"/>
        <column name="street" type="STRING"/>
        <column name="city" type="STRING"/>
        <column name="state" type="STRING"/>
        <column name="zip" type="NUMERIC"/>
    </loadUpdateData>
</changeSet>

表格定义

<changeSet author="ranbir" id="122">
    <preConditions onFail="MARK_RAN">
        <not><tableExists tableName="address"/></not>
    </preConditions>
    <comment>Create Table</comment>
    <createTable tableName="address" remarks="Table contains addresses">
        <column name="address_id" type="BIGSERIAL" remarks="Uniquely identifies rows in the table">
            <constraints nullable="false" primaryKey="true" primaryKeyName="pk_address" />
        </column>
        <column name="street" type="VARCHAR(250)">
        </column>
        <column name="city" type="VARCHAR(250)"/>
        <column name="state" type="VARCHAR(250)"/>
        <column name="zip" type="INTEGER"/>
    </createTable>
</changeSet>

0 个答案:

没有答案