0

I'm using FlywayDB v11.13.0 (latest as from now) and am targeting it against a PostgreSQL 17.6 database. I specify a schema like this:

String connectionUrl = UriBuilder.fromUri(connectionUrl).replaceQueryParam("currentSchema", dbSchema).build().toString();

Flyway.configure()
            .cleanDisabled(false)
            .validateMigrationNaming(true)
            .dataSource(connectionUrl, databaseUsername, databasePassword)
            .defaultSchema(schemaName)
            .schemas(schemas.toArray(new String[0]))
            .locations(locations.toArray(new String[0]))
            .initSql(initSql.toString())
            .baselineOnMigrate(true)
            .outOfOrder(outOfOrder)
            .load();

And this is a piece of a migration script:

create table ASSET (
  ID                 varchar(22)              not null,
  ATTRIBUTES         jsonb,
  CREATED_ON         timestamp with time zone not null,
  NAME               varchar(1023)            not null,
  PARENT_ID          varchar(22),
  PATH               ltree,
  REALM              varchar(255)             not null,
  TYPE               varchar(500)             not null,
  ACCESS_PUBLIC_READ boolean                  not null,
  VERSION            int8                     not null,
  primary key (ID),
  check (ID != PARENT_ID)
);

But the table is created in the public schema instead of my specific schema. Ive also tried adding to use the schema in the initSQL:

initSql.append("CREATE SCHEMA IF NOT EXISTS ").append(schemaName).append(";");
initSql.append("SET search_path TO ").append(schemaName).append(", public;");

But that doesn't help either.

The only thing what works is adding the SET search_path TO statement in the migration script itself, something which I don't prefer, specially if FlywayDB seems to support specifying schema's.

My question am I missing something here or is there a bug in FlywayDB?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.