2012-04-24 105 views

回答

4

documentation描述了changeLogPropertyDefined前提條件。

下面的例子爲我工作得很好:

<?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" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd"> 

    <changeSet author="mark (generated)" id="mark-1"> 
     <preConditions onFail="HALT"> 
      <changeLogPropertyDefined property="testing" value="1"/> 
     </preConditions> 

     <createTable tableName="TEST001"> 
      <column name="ID" type="VARCHAR(10)"> 
       <constraints nullable="false"/> 
      </column> 
      <column name="X" type="VARCHAR(9)"> 
       <constraints nullable="false"/> 
      </column> 
      <column name="Y" type="DECIMAL(7,2)"/> 
      <column name="Z" type="DECIMAL(7,2)"/> 
     </createTable> 
    </changeSet> 

</databaseChangeLog> 

我從Maven的運行liquibase。測試屬性可以從命令行設置如下:

mvn -Dtesting=1 compile 
+0

哇,我必須是盲人,不知道我怎麼會錯過這個:)謝謝你的回答! – nansen 2012-04-24 20:20:31

+0

@nansen前提條件名稱具有誤導性。我必須測試它是否適用於普通的Java屬性 – 2012-04-24 20:28:42

相關問題