2

I have a PostgreSQL Database that is setup using Liquibase. When I run liquibase:dropAll using maven it drop me everything but trigger functions. Is there a way that with that maven goal also triggerfunctions are dropped?

Since when I reapply my changeset after the dropAll it fails to create the already existing functions.

Tarion
  • 16,283
  • 13
  • 71
  • 107

1 Answers1

3

Unfortuantely no. The way dropAll is implemented is that it uses the liquibase snapshot function to find all objects to drop which works fine except for object types not looked for by snapshot. Snapshot handles standard types like tables, columns, views, and sequences but does not get into more database-specific types like triggers, functions, procedures, user defined types, etc. Since snapshot does not know about triggers, dropAll cannot know to drop them.

If you are using postgresql, the easiest way may be to just run

drop schema public cascade;
create schema public;

as described in "Drop all tables in PostgreSQL?" rather than use liqubase dropAll.

Community
  • 1
  • 1
Nathan Voxland
  • 15,453
  • 2
  • 48
  • 64
  • 1
    Or do you know a way to execute some additional SQL like the one you posted on liquibase:dropAll? – Tarion Mar 12 '14 at 17:01
  • There is no built in way, but the SQL above would replace what dropAll does anyway. – Nathan Voxland Mar 12 '14 at 18:29
  • Liquibase does have a rich extension system that would allow you to add support for snapshotting and then dropping triggers. My answer in http://stackoverflow.com/questions/22172239/how-to-extend-liquibase-to-generate-change-logs-with-stored-procedures-function describes how to do it for stored procs but triggers would be similar – Nathan Voxland Mar 12 '14 at 18:30
  • Another option is `drop owned by ... cascade` which will get rid of all database objects owned by the specific user. I usually use that, especially if more than one schema is involved –  Mar 13 '14 at 07:02