I'm trying to run the flywayMigrate
task from Gradle in my project after adding a new migration file but Flyway doesn't pick it up. I get this output:
Flyway Community Edition 5.2.4 by Boxfuse
Database: jdbc:postgresql://localhost:5432/mydb (PostgreSQL 10.6)
Successfully validated 6 migrations (execution time 00:00.105s)
Current version of schema "public": 5
Schema "public" is up to date. No migration necessary.
So it detects that I have 6 migrations but it doesn't execute the new file I just added (V6
) and insists on saying that the schema is up to date even if it isn't.
This is how my config looks like:
{
url = database_url
user = database_user
password = database_password
driver = database_driver
schemas = ["public"]
locations = ["filesystem:shared/src/main/resources/db/migration"]
table = "flyway_schema_history"
sqlMigrationPrefix = "V"
sqlMigrationSuffix = ".sql"
placeholderPrefix = "\${"
placeholderSuffix = "}"
target = "5.1"
}
I checked every setting and it is ok, It picks up the first 5 migration files if I delete all tables but for some reason the 6th one is not picked up. (I even tried adding a 7th one but it is not working either)
I tried to run the sql
in the 6th migration file and it runs OK so there is probably a problem with Flyway.
If I run with the debug
flag I can see that it even parses and reads out the sql from the file but all migrations are filtered out. What am I doing wrong?
...
15:23:34.893 [DEBUG] [org.flywaydb.core.internal.sqlscript.SqlScript] Parsing V5__some_migration_5.sql ...
15:23:34.893 [DEBUG] [org.flywaydb.core.internal.sqlscript.SqlScript] Found statement at line 1: ...
...
15:23:34.894 [DEBUG] [org.flywaydb.core.internal.sqlscript.SqlScript] Parsing V6__some_migration_6.sql ...
15:23:34.894 [DEBUG] [org.flywaydb.core.internal.sqlscript.SqlScript] Found statement at line 1: ...
15:23:34.894 [DEBUG] [org.flywaydb.core.internal.scanner.Scanner] Filtering out resource: shared/src/main/resources/db/migration/V1__some_migration_1.sql (filename: V1__some_migration_1.sql)
15:23:34.895 [DEBUG] [org.flywaydb.core.internal.scanner.Scanner] Filtering out resource: shared/src/main/resources/db/migration/V2__some_migration_2.sql (filename: V2__some_migration_2.sql)
15:23:34.895 [DEBUG] [org.flywaydb.core.internal.scanner.Scanner] Filtering out resource: shared/src/main/resources/db/migration/V3__some_migration_3.sql (filename: V3__some_migration_3.sql)
15:23:34.895 [DEBUG] [org.flywaydb.core.internal.scanner.Scanner] Filtering out resource: shared/src/main/resources/db/migration/V4__some_migration_4.sql (filename: V4__some_migration_4.sql)
15:23:34.895 [DEBUG] [org.flywaydb.core.internal.scanner.Scanner] Filtering out resource: shared/src/main/resources/db/migration/V5__some_migration_5.sql (filename: V5__some_migration_5.sql)
15:23:34.895 [DEBUG] [org.flywaydb.core.internal.scanner.Scanner] Filtering out resource: shared/src/main/resources/db/migration/V6__some_migration_6.sql (filename: V6__some_migration_6.sql)
15:23:34.899 [DEBUG] [org.postgresql.jdbc.PgConnection] setAutoCommit = true
15:23:34.899 [INFO] [org.flywaydb.core.internal.command.DbValidate] Successfully validated 6 migrations (execution time 00:00.016s)
15:23:34.899 [DEBUG] [org.postgresql.jdbc.PgConnection] setAutoCommit = false
15:23:34.899 [DEBUG] [org.flywaydb.core.internal.command.DbSchemas] Schema "public" already exists. Skipping schema creation.
15:23:34.900 [DEBUG] [org.postgresql.jdbc.PgConnection] setAutoCommit = true
15:23:34.915 [INFO] [org.flywaydb.core.internal.command.DbMigrate] Current version of schema "public": 5
15:23:34.915 [INFO] [org.flywaydb.core.internal.command.DbMigrate] Schema "public" is up to date. No migration necessary.
What I see in the flyway_schema_history
is consistent with what the log says:
installed_rank version description type script checksum installed_by installed_on execution_time success
1 1 some migration 1 SQL V1__some_migration_1.sql 1640479949 myuser 2019-05-31 15:17:19.354850 26 true
2 2 some migration 2 SQL V2__some_migration_2.sql 1463373644 myuser 2019-05-31 15:17:19.394065 1 true
3 3 some migration 3 SQL V3__some_migration_3.sql 1872028758 myuser 2019-05-31 15:17:19.398957 9 true
4 4 some migration 4 SQL V4__some_migration_4.sql 762610066 myuser 2019-05-31 15:17:19.410718 5 true
5 5 some migration 5 SQL V5__some_migration_5.sql -355256115 myuser 2019-05-31 15:17:19.418077 1 true
:-)
You have target = "5.1"
in your config, but
target NO latest version
The target version up to which Flyway should run migrations.
Migrations with a higher version number will not be applied.
The string 'current' will be interpreted as MigrationVersion.CURRENT,
a placeholder for the latest version that has been applied to the database.
Look at Gradle Task: flywayMigrate
This is why you cannot process migration > 5.1