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).
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:
validate: Comment out
if (createViewStatement.isReplaceIfExists()) { validationErrors.checkDisallowedField("replaceIfExists", ...); }
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:
validate: Comment out if (createViewStatement.isReplaceIfExists()) { validationErrors.checkDisallowedField("replaceIfExists", ...); }
generateSql: String viewName = database.escapeViewName(statement.getSchemaName(), statement.getViewName()); if (statement.isReplaceIfExists()) { sql.add(new UnparsedSql("DROP VIEW " + viewName)); } sql.add(new UnparsedSql("CREATE VIEW " + viewName + " AS " + statement.getSelectQuery()));