Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL: clean fails when trying to drop aggregates added by extensions #2051

CatalinaMoisuc opened this issue Jun 25, 2018 · 3 comments


Copy link

@CatalinaMoisuc CatalinaMoisuc commented Jun 25, 2018

Which version and edition of Flyway are you using?
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Java API

Which database are you using (type & version)?

PostgreSQL 9.6

What did you do?

I added a new migration containing:

and then another one altering some columns to use CITEXT instead of VARCHAR.

What did you expect to see?

I expected org.flywaydb.core.Flyway.clean() to know how to clean up the extention.

What did you see instead?

I got this error:

Unable to clean schema "public"
SQL State  : 2BP01
Error Code : 0
Message    : ERROR: cannot drop function min(citext) because extension citext requires it
  Hint: You can drop extension citext instead.

	at org.flywaydb.core.internal.database.Schema.clean(
	at org.flywaydb.core.internal.command.DbClean$
	at org.flywaydb.core.internal.command.DbClean$
	at org.flywaydb.core.internal.util.jdbc.TransactionTemplate.execute(
	at org.flywaydb.core.internal.command.DbClean.cleanSchema(
	at org.flywaydb.core.internal.command.DbClean.clean(
	at org.flywaydb.core.Flyway.doClean(
	at org.flywaydb.core.Flyway.access$300(
	at org.flywaydb.core.Flyway$3.execute(
	at org.flywaydb.core.Flyway$3.execute(
	at org.flywaydb.core.Flyway.execute(
	at org.flywaydb.core.Flyway.clean(
	at ….Migrations.clean(
	at ….Migrations.execute(
	at ….Main.main(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at org.codehaus.mojo.exec.ExecJavaMojo$
Caused by: org.postgresql.util.PSQLException: ERROR: cannot drop function min(citext) because extension citext requires it
  Hint: You can drop extension citext instead.
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(
	at org.postgresql.core.v3.QueryExecutorImpl.execute(
	at org.postgresql.jdbc.PgStatement.executeInternal(
	at org.postgresql.jdbc.PgStatement.execute(
	at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(
	at org.postgresql.jdbc.PgPreparedStatement.execute(
	at org.flywaydb.core.internal.util.jdbc.JdbcTemplate.execute(
	at org.flywaydb.core.internal.database.postgresql.PostgreSQLSchema.doClean(
	at org.flywaydb.core.internal.database.Schema.clean(
	... 20 common frames omitted


I was waiting since a few months ago for this fix to be released:
It was released finally in version: Flyway 5.1.0, but unfortunately it doesn't work for me.

@axelfontaine axelfontaine added this to the Flyway 5.2.0 milestone Jun 25, 2018
@axelfontaine axelfontaine changed the title Clean still doesn't clean up extensions PostgreSQL: clean fails when trying to drop aggregates added by extensions Jun 25, 2018
Copy link

@axelfontaine axelfontaine commented Jun 25, 2018

Thanks for reporting. It turns out citext creates an aggregate function instead of a regular one and we weren't dealing properly with that case. We have now fixed this by unifying to routine cleanup code.

axelfontaine added a commit to flyway/ that referenced this issue Jun 25, 2018
Copy link

@CatalinaMoisuc CatalinaMoisuc commented Jun 26, 2018

thank you @axelfontaine. Any idea when 5.1.4 will be released?

dohrayme pushed a commit to dohrayme/flyway that referenced this issue Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.