12

We are using flyway in our java, gradle spring based MVC application. I have kept my SQL files at src/main/resources/db/migration folder.

Below is my flyway gradle config file.

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"
    ]
}

When I run gradle flywayBaseline i get output as below.

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

It finds my sql file but then it does not execute it.

When I run flywayMigrate I get following output

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'

What is the issue here ?

ajm
  • 12,863
  • 58
  • 163
  • 234

3 Answers3

17

sqlMigrationPrefix is V by default and your files don't start with it. Rename your files or set the prefix to an empty value.

Axel Fontaine
  • 34,542
  • 16
  • 106
  • 137
8

I had a similar problem. In my case the file name was missing the double underscore after the version.

sweintritt
  • 366
  • 4
  • 10
0

I had similar issue and following file naming convention which is "V1_1__My_description.sql" solved the problem

Sumit
  • 15