lbitonti / liquibase-hana

Liquibase Hana extension
Apache License 2.0
11 stars 11 forks source link

Support of replaceIfExists for CreateView #17

Open pichlerm opened 6 years ago

pichlerm commented 6 years ago

We use CreateView with replaceIfExists="true" to change the definition of an existent view. Also by directly creating a CreateViewChange which does not exclude Hana support in its supportsReplaceIfExistsOption (because it does not know about it).

For MS-SQL the CreateViewGenerator creates some SQL that checks for existence of the view with a top level IF NOT EXISTS which I have not found for Hana. http://stackoverflow.com/questions/163246/sql-server-equivalent-to-oracles-create-or-replace-view

Hana supports an ALTER VIEW in addition to CREATE VIEW and DROP VIEW, however the ALTER VIEW requires an existent view, whereas replaceIfExists should both work when the view exists (replacing it) or not (creating it).

The simplest way for replaceIfExists I have found, was to do a DROP VIEW in case of CREATE VIEW (like done for MS-SQL in Liquibase 2.x); this will log an error if the view did not exist, but still create it afterwards.

Changes in CreateViewGeneratorHanaDB.java: