Found non-empty schema "public" without metadata table! Use init() or set initOnMigrate to true to initialize the metadata table.
public
schema called spatial_ref_sys
.When I run flyway migrate
on this database, I get the above error. Running init
seems to create the public.schema_version
table and mark version 1 as SUCCEDED without actually running the the migration file. I've also tried combinations of initOnMigrate
with no success. Flyway is not configured to manage any schemas.
Any ideas on how I can run a migration in this scenario?
The title is somewhat contradictory, as the database is indeed not virgin as you installed, through the PostGIS extension, a number of objects in the public schema.
You can either
flyway.schemas
to a new schema, say my_app, which will then be created automatically by Flyway. Your application should then use this one instead of public (recommended)flyway.baselineOnMigrate
to true
or invoke flyway.baseline()
against the public schema. This will work, but public will then contain a mix of both your application objects and the PostGIS objects