StrickeN69
StrickeN69

Reputation: 25

Maven flyway Found non-empty schema(s) "PUBLIC" but no schema history table

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 (I'm 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?

I'm using Java 8 and my dependency with Flyway looks like this:

<dependency>
        <groupId>org.flywaydb</groupId>
        <artifactId>flyway-core</artifactId>
</dependency>

Upvotes: 2

Views: 8271

Answers (1)

Barry
Barry

Reputation: 474

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.

Upvotes: 3

Related Questions