I am just learning spring boot with maven and I have encountered an error that I cannot resolve. I have attached a dependency from flyway and when I want to install it (Im clicking install on Lifecycle) I get this 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. What could be causing this and how to fix it?
Im using java 8 and my dependency with flyway looks like this:
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
CodePudding user response:
Spring Boot is trying to run Flyway migrate as part of a maven goal it has configured.
Found non-empty schema(s) "PUBLIC" but no schema history table.
The error message is stating that the default schema which Flyway is trying to run against, which is PUBLIC
, is not empty. As a result, Flyway know needs to know what the state the database before it is able to create a schema history table and migrate.
Use baseline() or set baselineOnMigrate to true to initialize the schema history table.
These are the two ways you can correct this by creating a baseline to build your migrations upon. https://flywaydb.org/documentation/command/baseline
In spring boot, baseline on migrate can be configured with spring.flyway.baselineOnMigrate=true
.
Additionally, install
in Maven does not mean install the dependencies but builds and puts the build artifacts of your product in your .m2
maven repository.