There is an issue with Liquibase being unable to drop database views (on postgresql, others too possible):
It does not figure out what order to drop the views in, and when one view is dependant on another, it can fail to drop a view because others depend on it. 3.5.0 is cited as the next version of liquibase that will fix this, but DW 0.9.1 is on the current latest version 3.4.1, where this is broken.
Has anyone got a workaround for this issue?
I currently put some code like this in a script and run it before building the database from scratch:
psql -c "DROP DATABASE IF EXISTS somedb"
psql -c "DROP USER IF EXISTS somedb"
psql -c "CREATE USER somedb WITH PASSWORD 'somedb'"
psql -c "CREATE DATABASE somedb"
psql -c "GRANT ALL PRIVILEGES ON DATABASE somedb TO somedb"
However, this needs my local user to have superuser rights on postgres, ok for a script on my machine, but I need something more robust for running on automated build and integration environments.
I am thinking maybe one of the solutions here:
Just execute this SQL using JDBC:
SELECT 'DROP VIEW ' || table_name || ';'
FROM information_schema.views
WHERE table_schema NOT IN ('pg_catalog', 'information_schema')
AND table_name !~ '^pg_';
I could set up a 'command' to run the above, and run it each time before invoking a drop-all/migrate cycle. The drop-views/drop-all/migrate cycle would also likely be run prior to each integration test class.
Any thoughts or other workarounds?
Rupert