在多种环境中配置maven和flyway,以及集成测试

时间:2015-03-07 21:19:43

标签: maven flyway

我有一个多模块Maven项目,我正在使用Flyway进行数据库迁移。目前,我在我的pom.xml中有这个片段:



<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>sql-maven-plugin</artifactId>
  <version>1.5</version>
  <dependencies>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>${mysql-connector-java.version}</version>
    </dependency>
  </dependencies>
  <executions>
    <execution>
      <id>drop-db-before-test-if-any</id>
      <phase>process-test-resources</phase>
      <goals>
        <goal>execute</goal>
      </goals>
      <configuration>
        <driver>${datasource.driver}</driver>
        <url>${datasource.url}</url>
        <username>${datasource.user}</username>
        <password>${dbPass}</password>
        <autocommit>true</autocommit>
        <srcFiles>
          <srcFile>${main.basedir}/db/test/drop_create_database_test.sql</srcFile>
        </srcFiles>
      </configuration>
    </execution>
  </executions>
</plugin>
&#13;
&#13;
&#13;

我如何将其转换为执行以下等效操作,以便它将使用flyway migration sql更好地模仿生产(在测试中,它目前使用db-test.properties,其中jpa.generate_ddl = true,以便表格是从JPA自动创建的:

&#13;
&#13;
mvn flyway:clean -P test
mvn flyway:init -Dflyway.initVersion=1 -Dflyway.initDescription="Initial Version" -P test
mvn flyway:migrate -P test
&#13;
&#13;
&#13;

谢谢!

0 个答案:

没有答案