Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is flyway ignoring my SQL migration files?

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 ?

like image 398
ashishjmeshram Avatar asked Jan 22 '16 08:01

ashishjmeshram


2 Answers

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

like image 169
Axel Fontaine Avatar answered Nov 16 '22 03:11

Axel Fontaine


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

like image 3
sweintritt Avatar answered Nov 16 '22 04:11

sweintritt