在特定的changeSet上运行mvn liquibase:updateSQL

时间:2011-05-12 08:39:56

标签: maven liquibase

有些经验丰富的maven用户可能会帮助我:

如何将“可选参数”传递给liquibase作为maven目标运行时?

我想传递“changesToApply”,请参阅http://www.liquibase.org/manual/maven_updatesql

但是语法是什么? 这样的事情,但并不完全:

mvn liquibase:updateSQL -DchangesToApply=2

4 个答案:

答案 0 :(得分:6)

简短回答:

mvn liquibase:updateSQL -Dliquibase.changesToApply=2

长答案

转到您感兴趣的参数并查找它的表达式。 http://www.liquibase.org/manual/maven_updatesql#changesToApply

寻找

changesToApply:

The number of changes to apply to the database. By default this value is 0, which will result in all changes (not already applied to the database) being applied.
Type: int
Required: No
Expression: ${liquibase.changesToApply}
Default: 0

从此,您可以看到表达式为${liquibase.changesToApply}

Expression: ${liquibase.changesToApply}

这就是你应该使用的

答案 1 :(得分:1)

来自Maven Liquibase plugin manual

  

执行Maven Liquibase插件的所有参数也可以   在插件的<configuration>部分中指定。以下是一个例子:

[...]
<plugin>
  <groupId>org.liquibase</groupId>
  <artifactId>liquibase-maven-plugin</artifactId>
  <version>2.0.1</version>
  <executions>
    <execution>
      <phase>process-resources</phase>
      <configuration>
        <changeLogFile>src/main/resources/org/liquiabse/business_table.xml</changeLogFile>
        <driver>oracle.jdbc.driver.OracleDriver</driver>
        <url>jdbc:oracle:thin:@tf-appserv-linux:1521:xe</url>
        <username>liquibaseTest</username>
        <password>pass</password>
      </configuration>
      <goals>
        <goal>update</goal>
      </goals>
    </execution>
  </executions>
</plugin>
[...]

答案 2 :(得分:1)

我是这样做的: mvn liquibase:updateSQL -P mysql -DskipTests -Dliquibase.changeLogFile = create.xml

我的更改日志文件是“create.xml” 和“mysql”预先配置的配置文件,以填充我的数据库属性文件。

确保尽管更改日志文件未在liquibase.properties文件中进行硬编码 和确保重建模块,因为maven目标将使用模块的target / classes目录中的liquibase.properties

答案 3 :(得分:0)

对于版本3.5.5应该在<executions>之外,如下所示:

<plugin>
      <groupId>org.liquibase</groupId>
      <artifactId>liquibase-maven-plugin</artifactId>
      <version>3.0.5</version>
      <configuration>
        <changeLogFile>src/main/resources/org/liquibase/business_table.xml</changeLogFile>
          <driver>oracle.jdbc.driver.OracleDriver</driver>
          <url>jdbc:oracle:thin:@tf-appserv-linux:1521:xe</url>
          <username>liquibaseTest</username>
          <password>pass</password>
        </configuration>
      <executions>
        <execution>
          <phase>process-resources</phase>
          <goals>
            <goal>update</goal>
          </goals>
        </execution>
      </executions>
    </plugin>