tjholmes66
tjholmes66

Reputation: 1998

flyway 3.3 migrations with postgresql and postgis extension

I am at my wits end, and I don't what else I can try. I am trying to do a flyway clean on my local database. I have Postgres 9.4 latest with latest PostGIS extension. I am using the public schema to store 10 tables, and 7 sequences ... it's very small.

Now I am trying to do a simple FlywayDB 3.3 clean instruction with maven. I have the username and password and public schema listed in the maven configuration file. I constantly kept getting errors to suggest various views and tables are used by the PostGIS extension, so it won't delete them.

So, a search here, and on the Internet in general suggested I do: ALTER USER myuser WITH SUPERUSER; This did not solve my problems.

In other research, it was suggested to use another schema for data, and not the public schema. So, I created a new schema for my app, and moved over my sequences and tables, including table spatial_ref_sys. I updated the maven config to clean only this new schema ... but it says it cannot delete "spatial_ref_sys" because it is used by PostGIS.

I have 10 tables uses for my app, with 7 sequences ... I just want Flyway to clean my database, so I can try the baseline file to rebuild it. I am no expert in PostGIS, so I don't know if I can remnove that table without killing any spatial functionality I want to use in the future.

Thanks for any help, and please let me know if I can provide any other data.

Upvotes: 4

Views: 2101

Answers (2)

LiorH
LiorH

Reputation: 18824

As noted it's a known issue with flyway.

adding a file called beforeClean.sql with the statement:

   DROP EXTENSION IF EXISTS PostGIS;

Solves the problem

Upvotes: 2

Axel Fontaine
Axel Fontaine

Reputation: 35169

This is a known issue with no trivial solution but 2 good workarounds: https://github.com/flyway/flyway/issues/100

Upvotes: 4

Related Questions