Search code examples
spring-bootflyway

Adding 2nd flyway instance in new schema


I have an existing app, with an existing flyway migration script. It uses the public schema of the database it connects to.

I'm working on a 2nd app that, for database purposes, will access the public and ABC schema, with read-access to public and read/write access to ABC. I'd like the 2nd app to handle its own flyway migration scripts for schema ABC. This app's instance of flyway can ignore the public schema completely.

When I run the app, I get the following in my logs

2018-12-04 09:16:02.871  WARN 71133 --- [  restartedMain] o.f.c.i.s.JdbcTableSchemaHistory         : Could not find schema history table "public"."flyway_schema_history", but found "public"."schema_version" instead. You are seeing this message because Flyway changed its default for flyway.table in version 5.0.0 to flyway_schema_history and you are still relying on the old default (schema_version). Set flyway.table=schema_version in your configuration to fix this. This fallback mechanism will be removed in Flyway 6.0.0.
2018-12-04 09:16:02.904  INFO 71133 --- [  restartedMain] o.f.core.internal.command.DbValidate     : Successfully validated 49 migrations (execution time 00:00.028s)
2018-12-04 09:16:02.935  INFO 71133 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Current version of schema "public": 201808271553
2018-12-04 09:16:02.935  WARN 71133 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Schema "public" has version 201808271553, but no migration could be resolved in the configured locations !
2018-12-04 09:16:02.940  INFO 71133 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Schema "public" is up to date. No migration necessary.

This is my application.yaml

flyway:
  url: jdbc:postgresql://localhost:5432/data
  schemas: ABC
  table: schema_version_module1
  user: flyway
  password: flyway

I'd like flyway to use the mqa schema (that I've created manually) for everything, instead of relying on the public schema for the migration history.

This is a spring boot java app, with flyway-core:5.2.3 defined in my build.gradle


Solution

  • Your Flyway config should be put under the Spring namespace starting with Spring Boot 2.0. See https://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html#howto-use-a-higher-level-database-migration-tool