CreateViewGenerator generates incorrect SQL for PostgreSQL
See original GitHub issueDescription CORE-2377 removed the DROP statement generation for PostgreSQL in CreateViewGenerator (commit).
The ticket states that DROP + CREATE can be substituted for a “CREATE OR REPLACE” statement in PostgreSQL in all cases. However, this assumption proved to be incorrect. Quoting PostgreSQL docs for CREATE VIEW:
CREATE OR REPLACE VIEW is similar, but if a view of the same name already exists, it is replaced. The new query must generate the same columns that were generated by the existing view query (that is, the same column names in the same order and with the same data types), but it may add additional columns to the end of the list. The calculations giving rise to the output columns may be completely different.
Changesets that were created for versions < 3.7.0 containing createView
are now broken because of this change.
To Reproduce See here: https://github.com/abelk2/liquibase-postgres-createview/blob/master/README.md
Expected behavior
For PostgreSQL, createView
change withreplaceIfExists = "true"
should replace existing database views even when field names / data types are changed just like it did before 3.7.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:22 (16 by maintainers)
Top GitHub Comments
Thank you for the clarifications @nvoxland ! I have made initial code changes already. Will try to update them based on the feedback and, hopefully, submit them this coming weekend.
To answer your question on global properties in general, we have ConfigurationDefinitions like get set in SqlConfiguration and GlobalConfiguration which define the global properties. Then you can always get the value in code via something like
GlobalConfiguration.LIQUIBASE_CATALOG_NAME.getCurrentValue()
and it will get the value however it was set.