2016-05-13 84 views
1

我使用Liquibase 3.4.2(通過Maven插件)。我有一個db.changelog-master.xml文件,其中包含另外兩個文件:db.changelog-2.6.xmldb.changelog-2.10使用回滾標籤changeSetId和changeSetAuthor時找不到Liquibase ChangeSet

db.changelog-master.xml看起來是這樣的:

<?xml version="1.0" encoding="UTF-8"?> 
<databaseChangeLog logicalFilePath="/database-migration/db.changelog-master.xml" 
       xmlns="http://www.liquibase.org/xml/ns/dbchangelog" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd"> 
    <include file="versions/db.changelog-2.6.xml" relativeToChangelogFile="true"/> 
    <include file="versions/db.changelog-2.10.xml" relativeToChangelogFile="true"/> 

</databaseChangeLog> 

db.changelog 2.10我創建一個<changeSet>刪除一些數據,並在<rollback>標籤我參考了創建相同數據的<changeSet>。這兩個<changeSet>看起來是這樣的:

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<databaseChangeLog logicalFilePath="/database-migration/versions/db.changelog-2.10.xml" 
       xmlns="http://www.liquibase.org/xml/ns/dbchangelog" 
       xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd"> 
    <changeSet id="1" author="my-user"> 
     <insert tableName="TABLE"> 
      <!-- SOME DATA --> 
     </insert> 
    </changeSet> 

    <changeSet id="2" author="my-user"> 
     <delete tableName="TABLE" /> 
     <rollback changeSetId="1" changeSetAuthor="my-user" /> 
    </changeSet> 
</databaseChangeLog> 

的問題是,當我嘗試運行update命令我結束了具有以下錯誤消息:

更改設置/數據庫遷移/版本/db.changelog-2.10.xml::1::my-user不存在

我做錯了什麼或這是一個Liquibase錯誤?

回答

0

請檢查<changeSet id="1">中打開和關閉XML標籤的匹配情況。在你的例子中,我看到開始標記<insert>並關閉標記</update>。也許你的問題導致了不正確的輸入數據。很奇怪liquibase中的XML解析器沒有檢測到這一點。

嘗試將結束標記</update>更換爲更合適的</insert>