'Found non-empty schema(s) "public" but no schema history table. Use baseline() or set baselineOnMigrate to true to initialize the schema history table
I know this has been asked previously but I am spinning in circles here....
I have a postgres 14 database and a Springboot application running flyway-db:7.13.0 and flyway-core:8.5.10
I am using RDS. I created a new database manually using root account. When I run my springboot my flyway migration fails with the error
Found non-empty schema(s) "public" but no schema history table. Use baseline() or set baselineOnMigrate to true to initialize the schema history table.
I understand the reason why this is happening but when I add the baselineVersion and baselineOnMigrate to my flyway gradle config it still doesn't work. I even added
flyway {
url = dbUrl
user = dbUser
password = dbPassword
schemas = ['public']
baselineVersion = '0.0'
baselineOnMigrate = true
locations = ["filesystem:${dbMigrationPath}"]
}
also I added
spring.flyway.baseline-on-migrate = true
to my application.properties
What confuses me the most is if I start the application pointing to the default postgres database with the root user. The migration works and it creates the flyway history table. but when I run it pointing to the newly created database it doesn't work.
Any idea?
Solution 1:[1]
I figured it out. It turned out I needed to add the baselineOnMigration flag to my configuration
Flyway.configure().baselineOnMigrate(true).dataSource(new TransactionAwareDataSourceProxy(dataSource)).load();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user955165 |
