运行liquibase

时间:2018-07-11 14:17:57

标签: database hibernate liquibase

我正在一个模块化体系结构项目中,每个模块都有自己的liquibase。假设我有两个模块名称module-a和module-b。模块b的liquibase具有模块a的liquibase中定义的列的引用。通过模块b的liquibase插入数据时,获得外键异常,而在模块a的liquibase中定义了外键数据。

下面是模块aquiquibase的描述:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
    http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">  

<changeSet author="mukesh" id="1227303685425-4">
        <createTable tableName="concept">
            <column autoIncrement="true" name="concept_id" type="int">
                <constraints nullable="false" primaryKey="true"/>
            </column>
            <column defaultValueBoolean="false" name="retired" type="BOOLEAN">
                <constraints nullable="false"/>
            </column>
            <column name="short_name" type="varchar(255)"/>
            <column name="description" type="text"/>
            <column name="form_text" type="text"/>
            <column defaultValueNumeric="0" name="datatype_id" type="int">
                <constraints nullable="false"/>
            </column>
            <column defaultValueNumeric="0" name="class_id" type="int">
                <constraints nullable="false"/>
            </column>
            <column defaultValueBoolean="false" name="is_set" type="BOOLEAN">
                <constraints nullable="false"/>
            </column>
            <column defaultValueNumeric="0" name="creator" type="int">
                <constraints nullable="false"/>
            </column>
            <column name="date_created" type="DATETIME">
                <constraints nullable="false"/>
            </column>
            <column name="version" type="varchar(50)"/>
            <column name="changed_by" type="int"/>
            <column name="date_changed" type="DATETIME"/>
            <column name="retired_by" type="int"/>
            <column name="date_retired" type="DATETIME"/>
            <column name="retire_reason" type="varchar(255)"/>
            <column name="uuid" type="char(38)" />
        </createTable>

 <createTable tableName="concept_answer">
            <column autoIncrement="true" name="concept_answer_id" type="int">
                <constraints nullable="false" primaryKey="true"/>
            </column>
            <column defaultValueNumeric="0" name="concept_id" type="int">
                <constraints nullable="false"/>
            </column>
            <column name="answer_concept" type="int"/>
            <column name="answer_drug" type="int"/>
            <column defaultValueNumeric="0" name="creator" type="int">
                <constraints nullable="false"/>
            </column>
            <column name="date_created" type="DATETIME">
                <constraints nullable="false"/>
            </column>
            <column name="sort_weight" type="double precision"></column>
            <column name="uuid" type="char(38)" />
        </createTable>
        <modifySql dbms="mssql">
                <replace replace="CHAR(38)" with="UNIQUEIDENTIFIER NOT NULL DEFAULT NEWSEQUENTIALID()" />
     </modifySql>


<insert tableName="concept">
            <column name="concept_id" valueNumeric="51"/>
            <column name="retired" valueBoolean="true"/>
            <column name="short_name" value=""/>
            <column name="description" value=""/>
            <column name="form_text"/>
            <column name="datatype_id" valueNumeric="4"/>
            <column name="class_id" valueNumeric="4"/>
            <column name="is_set" valueBoolean="false"/>
            <column name="creator" valueNumeric="1"/>
            <column name="date_created" valueDate="2004-01-01"/>

            <column name="version" value=""/>
            <column name="changed_by"/>
            <column name="date_changed"/>
            <column name="retired_by"/>
            <column name="date_retired"/>
            <column name="retire_reason"/>
        </insert>
  </changeSet>

</databaseChangeLog>

模块b液基描述:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
    http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<changeSet author="mukesh" id="1227303685425-4">
<insert tableName="concept_answer">
            <column name="concept_answer_id" valueNumeric="1"/>
            <column name="concept_id" valueNumeric="51"/>
            <column name="answer_concept" valueNumeric="1115"/>
            <column name="answer_drug"/>
            <column name="creator" valueNumeric="1"/>
            <column name="date_created" valueDate="2005-01-26"/>
        </insert>
</changeSet>

</databaseChangeLog>

请,有人帮我解决这个问题。

0 个答案:

没有答案