We use Liquibase to manage our Oracle DB schema. We also use HSQL DB for integration tests. I’d like to use Liquibase to build the HSQL schema as well (it’s currently built programatically from java - so I’m using the Liquibase java API to trigger it in this instance).
We have several view changeSets, which are run towards the end of any liquibase migration whenever their contents are changed:
- SELECT …
Liquibase for HSQL DB doesn’t support replaceIfExists, so this approach fails.
I can see a few options, but they’re all ugly. Has anyone found a better approach?
- Drop each view if it exists, then create, on every migration. This works, but creates a huge amount of redundant SQL for even small changes - it breaks runOnChange.
- Use duplicate changeSets for HSQL DB and for Oracle - Oracle will use replaceIfExists and runOnChange, and HSQL DB will follow the first pattern - drop if exists, then create. This means duplicating our view logic.
- Go through the liquibase code and try to support replaceIfExists on HSQL DB - Liquibase could issue a drop view command, rather than relying on the underlying DB to handle it. Good, but I don’t have time!
[ note - also on Stack Overflow]