2017-09-19 147 views
0

你能帮助flyway为什么不能安装脚本 ?FlyWay迁移脚本

我的模式是空的,只有一个表创建飞路。但它也是空的。

我该如何正确配置FlyWay?我的脚本有如下形式

V1__20170918_Initial_structure.sql

18:43:30,773 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG Flyway:40 - DDL Transactions Supported: false 
18:43:30,773 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG Flyway:40 - Schema: TEST_SERVER 
18:43:30,778 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG FeatureDetector:40 - Spring Jdbc available: false 
18:43:30,779 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG SqlScriptFlywayCallback:40 - Scanning for SQL callbacks ... 
18:43:30,779 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG ClassPathScanner:40 - Scanning for classpath resources at 'classpath:db/migration' (Prefix: '', Suffix: '.sql') 
18:43:30,780 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG ClassPathScanner:40 - Determining location urls for classpath:db/migration using ClassLoader ModuleClassLoader for Module "deployment.mobile.bank.services-1.0.5.ear.flyway-1.0-SNAPSHOT.jar:main" from Service Module Loader ... 
18:43:30,780 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG ClassPathScanner:40 - Scanning URL: vfs:/E:/Soft/Server_10.1.0/bin/content/mobile.bank.services-1.0.5.ear/flyway-1.0-SNAPSHOT.jar/db/migration/ 
18:43:30,780 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG FeatureDetector:40 - JBoss VFS v2 available: false 
18:43:30,781 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG FeatureDetector:40 - JBoss VFS v3 available: true 
18:43:30,782 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG JBossVFSv3ClassPathLocationScanner:40 - Scanning starting at classpath root on JBoss VFS: E:\Soft\Server_10.1.0\bin\content\mobile.bank.services-1.0.5.ear\flyway-1.0-SNAPSHOT.jar\/ 
18:43:30,834 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG DbValidate:40 - Validating migrations ... 
18:43:30,836 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG ClassPathScanner:40 - Scanning for classpath resources at 'classpath:db/migration' (Prefix: 'V', Suffix: '.sql') 
18:43:30,836 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG ClassPathScanner:40 - Scanning URL: vfs:/E:/Soft/Server_10.1.0/bin/content/mobile.bank.services-1.0.5.ear/flyway-1.0-SNAPSHOT.jar/db/migration/ 
18:43:30,836 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG FeatureDetector:40 - JBoss VFS v2 available: false 
18:43:30,836 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG ClassPathScanner:40 - Scanning for classpath resources at 'classpath:db/migration' (Prefix: 'R', Suffix: '.sql') 
18:43:30,836 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG ClassPathScanner:40 - Scanning URL: vfs:/E:/Soft/Server_10.1.0/bin/content/mobile.bank.services-1.0.5.ear/flyway-1.0-SNAPSHOT.jar/db/migration/ 
18:43:30,837 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG FeatureDetector:40 - JBoss VFS v2 available: false 
18:43:30,837 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG ClassPathScanner:40 - Scanning for classes at 'classpath:db/migration' (Implementing: 'org.flywaydb.core.api.migration.jdbc.JdbcMigration') 
18:43:30,837 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG ClassPathScanner:40 - Scanning URL: vfs:/E:/Soft/Server_10.1.0/bin/content/mobile.bank.services-1.0.5.ear/flyway-1.0-SNAPSHOT.jar/db/migration/ 
18:43:30,838 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG FeatureDetector:40 - JBoss VFS v2 available: false 
18:43:30,853 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 INFO DbValidate:44 - Successfully validated 0 migrations (execution time 00:00.018s) 
18:43:30,859 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG DbSchemas:40 - Schema "TEST_SERVER" already exists. Skipping schema creation. 
18:43:30,935 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG Table:40 - Locking table "TEST_SERVER"."SERVER_VERSION_DB"... 
18:43:30,936 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 DEBUG Table:40 - Lock acquired for table "TEST_SERVER"."SERVER_VERSION_DB" 
18:43:30,943 INFO [stdout] (ServerService Thread Pool -- 20) 2017-09-19 18:43:30 DEBUG Reflections:184 - going to scan these urls: 
18:43:30,943 INFO [stdout] (ServerService Thread Pool -- 20) vfs:/E:/Soft/Server_10.1.0/bin/content/mobile.bank.services-1.0.5.ear/service-web-1.0-SNAPSHOT.war/WEB-INF/classes/ 
18:43:30,943 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 INFO DbMigrate:44 - Current version of schema "TEST_SERVER": << Empty Schema >> 
18:43:30,945 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 INFO DbMigrate:44 - Schema "TEST_SERVER" is up to date. No migration necessary. 
18:43:30,974 INFO [stdout] (ServerService Thread Pool -- 14) 2017-09-19 18:43:30 INFO DEBUG_LOGGER:48 - FlyWayMigrator - flywayMigrateStop 

我的源代码

public void flywayMigrateStart() { 
    LoggerUtil.getDEBUG_LOGGER().info("FlyWayMigrator - flywayMigrateStart"); 
    String flywayMinVersion = FlyWayProperty.getInstance().getProperty(FlyWayProperty.FLYWAY_MIN_VERSION); 

    if (flywayMinVersion != null) { 
     Flyway flyway = new Flyway(); 
     try { 
      flyway.setDataSource(createDataSource()); 
      flyway.setTable(FlyWayProperty.getInstance().getProperty(FlyWayProperty.FLYWAY_MIGRATION_TABLE_NAME)); 
      flyway.setBaselineVersionAsString(FlyWayProperty.getInstance().getProperty(FlyWayProperty.FLYWAY_BASELINE_VERSION)); 
      flyway.setSqlMigrationSeparator(FlyWayProperty.getInstance().getProperty(FlyWayProperty.FLYWAY_MIGRATION_SEPARATOR)); 
      flyway.setEncoding(FlyWayProperty.getInstance().getProperty(FlyWayProperty.FLYWAY_ENCODING)); 
      flyway.setSchemas(FlyWayProperty.getInstance().getProperty(FlyWayProperty.ORACLE_DB_USERNAME)); 
      flyway.setBaselineOnMigrate(true); 
      flyway.migrate(); 
      flywayMigrateStop(); 
     } catch (Exception e) { 
      throw new RuntimeException(e.getMessage(), e); 
     } 
    } 
} 

我的属性文件

ORACLE_DB_DRIVER_CLASS=oracle.jdbc.driver.OracleDriver 
ORACLE_DB_URL=jdbc:oracle:thin:@192.168.100.210:1521:DB 
ORACLE_DB_USERNAME=TEST_SERVER 
ORACLE_DB_PASSWORD=TEST_SERVER 
FLYWAY_MIN_VERSION=V1 
FLYWAY_MIGRATION_TABLE_NAME=SERVER_VERSION_DB 
FLYWAY_BASELINE_VERSION=1.0.0 
FLYWAY_MIGRATION_SEPARATOR=# 
FLYWAY_ENCODING=UTF-8 
+0

需要更多信息。 –

+0

什么不起作用?那些日志声明表明,Flyway认为不需要迁移。 '''18:43:30,945 INFO [stdout](ServerService线程池 - 14)2017-09-19 18:43:30 INFO DbMigrate:44 - 架构“TEST_SERVER”是最新的。没有必要的迁移.''' –

+0

我添加了一些信息 – LeshaRB

回答

1

迁飞不能因此找到你的迁移文件认为everythin g是最新的:

INFO DbValidate:44 - Successfully validated 0 migrations (execution time 00:00.018s) 

您需要指定一个位置或将您的迁移移动到它已经在搜索的位置。使用setLocations()即可。

0

如果你建立这个罐子 - 使用maven迁徙路线-1.0-SNAPSHOT.jar,然后确保的src/main /资源已经包含您的V1__20170918_Initial_structure.sql

一个DB /迁移文件夹不要让我知道,如果它能够解决您的问题。