2016-03-03 22 views
0

我在文件夾中的腳本是這樣的:遷飛位置 - 指向單個SQL腳本

D:/dev/DatabaseSetup/oracle/010__script.sql 
D:/dev/DatabaseSetup/oracle/020__script.sql 
D:/dev/DatabaseSetup/oracle/030__script.sql 
D:/dev/DatabaseSetup/oracle/040__script.sql 
D:/dev/DatabaseSetup/oracle/050__script.sql 

我想保持在同一個文件夾中的所有腳本,卻忽略了他們中的一些遷移。準確地說,我想包括眼前這個腳本路徑pom.xml

<locations> 
    <location>filesystem:oracle/020__script.sql</location> 
    <location>filesystem:oracle/030__script.sql</location> 
    <location>filesystem:oracle/040__script.sql</location> 
</locations> 

D:/dev/DatabaseSetup/oracle/pom.xml

我看了這個question,但發現我無法指定單個sql腳本進行遷移(在接受的答案中,它使用的classpath指向java包)。

這有可能嗎?當我改變<locations>

<locations> 
    <location>filesystem:oracle</location> 
</locations> 

遷徙路線執行所有腳本

[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:3.2.1:migrate (default-cli) on proje 
ct DatabaseSetup: org.flywaydb.core.api.FlywayException: Unable to scan for SQL migrations in lo 
cation: filesystem:D:/dev/DatabaseSetup/oracle/020__script.sql: Invalid filesystem path: 
D:/dev/DatabaseSetup/oracle/020__script.sql -> [Help 1] 

:我得到了下面的錯誤。

回答

0

我通過爲要執行的腳本定義文件名模式解決了我的問題,然後將它們複製到flyway將尋找遷移的特定文件夾。

例如,如果文件名模式是**__pattern**.sql,配置將是:

<plugin> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <version>1.8</version> 
    <executions> 
     <execution> 
      <id>copy-flyway-scripts</id> 
      <phase>compile</phase> 
      <configuration> 
       <target name="copy-flyway-scripts"> 
        <echo>Copying SQL scripts</echo> 
        <copy todir="./target/flyway"> 
         <fileset dir="./src/main/resources/oracle" > 
          <include name="**__pattern**.sql"/> 
         </fileset> 
        </copy> 
       </target> 
      </configuration> 
      <goals> 
       <goal>run</goal> 
      </goals> 
     </execution> 
    </executions> 
</plugin> 
<plugin> 
    <groupId>org.flywaydb</groupId> 
    <artifactId>flyway-maven-plugin</artifactId> 
    <version>3.0</version> 
    <configuration> 
     <driver>${db-driver-name}</driver> 
     <url>${db-url}</url> 
     <user>${db-user-name}</user> 
     <password>${db-user-password}</password> 
     <locations> 
      <location>filesystem:./target/flyway</location> 
     </locations> 
     <schemas> 
      <schema>SCHEMA</schema> 
     </schemas> 
    </configuration> 
</plugin> 
1

不,這是不可能的。你可以做的是創建兩個不同的文件夾,並在執行da命令來運行Flyway時,你傳遞一個參數來說明Flyway應該讀取的女巫文件夾。