2017-04-19 80 views
1

我使用的遷徙路線版本4.1.2遷飛不拿起我的SQL文件遷移

我有一個名爲SAPDATA架構。我正在尋找執行下面的腳本V0.0.1_1__baseline.sql。我看到我的sql文件被flyway忽略,它已經過濾了我的資源。

我已經在架構中有表,所以我將baselineOnMigrate設置爲true以遷移我的腳本。

請你讓我知道我是否應該明確地設置模式名稱? 我不知道爲什麼我的SQL文件被過濾出來?

請你能告訴我是否缺少我的flyway的任何特定設置,以便我的sql被執行?

執行代碼

 @Override 
     protected void doOperation(DatabaseConfig.DataSourceConfig databaseConfig, String location) { 
      final Flyway flyway = new Flyway(); 
      flyway.setLocations(location); 
      flyway.setDataSource(databaseConfig.getUrl(), databaseConfig.getUsername(), databaseConfig.getPassword()); 
      flyway.setBaselineOnMigrate(true); 
      flyway.migrate(); 
     } 

**Execution logs** 
17:51:46.073 [main] DEBUG org.flywaydb.core.internal.util.FeatureDetector - Spring Jdbc available: false 
17:51:46.074 [main] DEBUG org.flywaydb.core.internal.callback.SqlScriptFlywayCallback - Scanning for SQL callbacks ... 
17:51:46.074 [main] DEBUG org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner - Scanning for classpath resources at 'classpath:db/migration/sap' (Prefix: '', Suffix: '.sql') 
17:51:46.074 [main] DEBUG org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner - Determining location urls for classpath:db/migration/sap using ClassLoader [email protected] ... 
17:51:46.074 [main] DEBUG org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner - Scanning URL: file:/C:/dev/workspaces/intellij-workspaces/reference-data-system/database/target/classes/db/migration/sap 
17:51:46.075 [main] DEBUG org.flywaydb.core.internal.util.FeatureDetector - JBoss VFS v2 available: false 
17:51:46.077 [main] DEBUG org.flywaydb.core.internal.util.scanner.classpath.FileSystemClassPathLocationScanner - Scanning starting at classpath root in filesystem: C:\dev\workspaces\intellij-workspaces\reference-data-system\database\target\classes\ 
17:51:46.077 [main] DEBUG org.flywaydb.core.internal.util.scanner.classpath.FileSystemClassPathLocationScanner - Scanning for resources in path: C:\dev\workspaces\intellij-workspaces\reference-data-system\database\target\classes\db\migration\sap (db/migration/sap) 
17:51:46.098 [main] DEBUG org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner - Found resource: db/migration/sap/V0.0.1_1__baseline.sql 
17:51:46.706 [main] DEBUG org.flywaydb.core.internal.command.DbValidate - Validating migrations ... 
17:51:46.757 [main] DEBUG org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner - Scanning for classpath resources at 'classpath:db/migration/sap' (Prefix: 'V', Suffix: '.sql') 
17:51:46.757 [main] DEBUG org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner - Scanning URL: file:/C:/dev/workspaces/intellij-workspaces/reference-data-system/database/target/classes/db/migration/sap 
17:51:46.757 [main] DEBUG org.flywaydb.core.internal.util.FeatureDetector - JBoss VFS v2 available: false 
17:51:46.774 [main] DEBUG org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner - Found resource: db/migration/sap/V0.0.1_1__baseline.sql 
17:51:46.777 [main] DEBUG org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner - Scanning for classpath resources at 'classpath:db/migration/sap' (Prefix: 'R', Suffix: '.sql') 
17:51:46.777 [main] DEBUG org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner - Scanning URL: file:/C:/dev/workspaces/intellij-workspaces/reference-data-system/database/target/classes/db/migration/sap 
17:51:46.778 [main] DEBUG org.flywaydb.core.internal.util.FeatureDetector - JBoss VFS v2 available: false 
17:51:46.789 [main] DEBUG org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner - Filtering out resource: db/migration/sap/V0.0.1_1__baseline.sql (filename: V0.0.1_1__baseline.sql) 
17:51:46.791 [main] DEBUG org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner - Scanning for classes at 'classpath:db/migration/sap' (Implementing: 'org.flywaydb.core.api.migration.jdbc.JdbcMigration') 
17:51:46.791 [main] DEBUG org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner - Scanning URL: file:/C:/dev/workspaces/intellij-workspaces/reference-data-system/database/target/classes/db/migration/sap 
17:51:46.791 [main] DEBUG org.flywaydb.core.internal.util.FeatureDetector - JBoss VFS v2 available: false 
17:51:46.803 [main] DEBUG org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner - Filtering out resource: db/migration/sap/V0.0.1_1__baseline.sql (filename: V0.0.1_1__baseline.sql) 
17:51:47.107 [main] INFO org.flywaydb.core.internal.command.DbValidate - Successfully validated 2 migrations (execution time 00:00.398s) 
17:51:47.240 [main] INFO org.flywaydb.core.internal.dbsupport.sqlserver.SQLServerDbSupport - SQLServer does not support setting the schema for the current session. Default schema NOT changed to SAPDATA 
17:51:47.330 [main] DEBUG org.flywaydb.core.internal.command.DbSchemas - Schema [SAPDATA] already exists. Skipping schema creation. 
17:51:48.343 [main] DEBUG org.flywaydb.core.internal.dbsupport.Table - Locking table [SAPDATA].[schema_version]... 
17:51:48.394 [main] DEBUG org.flywaydb.core.internal.dbsupport.Table - Lock acquired for table [SAPDATA].[schema_version] 
17:51:48.793 [main] INFO org.flywaydb.core.internal.command.DbMigrate - Current version of schema [SAPDATA]: 1 
17:51:48.877 [main] INFO org.flywaydb.core.internal.command.DbMigrate - Schema [SAPDATA] is up to date. No migration necessary. 
+0

我不明白。您是否已經嘗試使用Flyway#setSchemas(String ... schemas)設置架構? –

+0

是的,我也嘗試過這個選項。出於某種原因,它過濾了我的sql文件。 – megan

+0

因此,如果您使用#setSchema(..),則會生成您發佈的日誌?因爲在代碼中你沒有。 –

回答

0

根據你的日誌,您已經有了版本1的模式,雖然你的腳本是用版本0

如果你希望你的腳本將應用於您必須增加它的版本,因爲所有版本低於當前版本的腳本都會被跳過。