Spring Boot 2.4.5.
FlyWay 6.5.5.
I decided to make an experiment on my local machine.
I dropped my app database.
All my migrations include my as schema for creating tables, sequences etc.
For instance:
create table if not exists my
(
name varchar not null
constraint category_pk primary key,
status varchar
);
I run ./gradlew api:flyWayMigrate.
my schema has been created along with tables from migrations under it.
But there is no flyway_schema_history tables under my schema.
Public schema has been created as well, but it contains only one table flyway_schema_history.
Wrapping up, my schema contains all tables, but doesn’t contain flyway_schema_history table. public schema contains flyway_schema_history table, but doesn’t contain other tables.
When app is being started, FlyWay complains that you have tables in my schema but you don’t have flyway_schema_history table for them, use baseline property.
Baseline property was not what I expected to have. I need the single schema - my with flyway_schema_history in it.
So I have added these lines into application.properties files.
spring.flyway.schemas=my
spring.flyway.default-schema=my
But it didn’t help.
Only by adding schemas = ['my'] in build.gradle FlyWay section, I have achieved the result, when there are all needed tables under my
schema along with flyway_schema_history table.
flyway {
url = 'jdbc:postgresql://localhost:5432/postgres'
user = 'postgres'
password = 'password'
locations = ['classpath:sql']
schemas = ['my']
}
So my question is why spring.flyway.schemas and spring.flyway.default-schema properties in application.properties don't work?
CodePudding user response:
i guess its because you are using jpa hibernate which also does migrations
