我们在java,基于gradle spring的MVC应用程序中使用flyway。我将我的SQL文件保存在src / main / resources / db / migration文件夹中。
以下是我的flyway gradle配置文件。
apply plugin: "org.flywaydb.flyway"
flyway {
driver = 'com.mysql.jdbc.Driver'
url = "jdbc:mysql://localhost:3306/java_app_test"
user = 'root'
password = ''
schemas = ['java_app_test']
outOfOrder = true
locations = [
//"filesystem:${project.projectDir}/dbScripts/migrations"
"classpath:db/migration"
]
}
当我运行gradle flywayBaseline时,我得到如下输出。
13:57:06.291 [DEBUG] [org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner] Found resource: db/migration/20160121042238016__initial.sql
13:57:06.292 [DEBUG] [org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner] Found resource: db/migration/20160122081606826__initial.sql
13:57:06.311 [DEBUG] [org.flywaydb.core.internal.command.DbSchemas] Schema `java_app_test` already exists. Skipping schema creation.
13:57:06.358 [DEBUG] [org.flywaydb.core.internal.metadatatable.MetaDataTableImpl] MetaData table `java_app_test`.`schema_version` successfully updated to reflect changes
13:57:06.422 [INFO] [org.flywaydb.core.internal.command.DbBaseline] Schema baselined with version: 1
它找到了我的sql文件,但它没有执行它。
当我运行flywayMigrate时,我得到以下输出
14:12:41.285 [DEBUG] [org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner] Filtering out resource: db/migration/20160121042238016__initial.sql (filename: 20160121042238016__initial.sql)
14:12:41.285 [DEBUG] [org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner] Filtering out resource: db/migration/20160122081606826__initial.sql (filename: 20160122081606826__initial.sql)
14:12:41.314 [INFO] [org.flywaydb.core.internal.command.DbValidate] Validated 1 migration (execution time 00:00.047s)
14:12:41.335 [DEBUG] [org.flywaydb.core.internal.command.DbSchemas] Schema `java_app_test` already exists. Skipping schema creation.
14:12:41.351 [DEBUG] [org.flywaydb.core.internal.dbsupport.Table] Locking table `java_app_test`.`schema_version`...
14:12:41.354 [DEBUG] [org.flywaydb.core.internal.dbsupport.Table] Lock acquired for table `java_app_test`.`schema_version`
14:12:41.358 [INFO] [org.flywaydb.core.internal.command.DbMigrate] Current version of schema `java_app_test`: 1
14:12:41.358 [WARN] [org.flywaydb.core.internal.command.DbMigrate] outOfOrder mode is active. Migration of schema `java_app_test` may not be reproducible.
14:12:41.359 [INFO] [org.flywaydb.core.internal.command.DbMigrate] Schema `java_app_test` is up to date. No migration necessary.
14:12:41.361 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':flywayMigrate'
这里有什么问题?
答案 0 :(得分:6)
sqlMigrationPrefix为V
,您的文件不会以它开头。重命名文件或将前缀设置为空值。
答案 1 :(得分:0)
我遇到了类似的问题,遵循“V1_1__My_description.sql”的文件命名约定解决了问题