|
|
PostgreSQL database is very restrictive when it comes to modifying existing objects. Very often when you try to ALTER TABLE or REPLACE VIEW it tells you that you cannot do it, because there’s another object (typically a view or materialized view), which depends on the one you want to modify. It seems that the only solution is to DROP dependent objects, make desired changes to the target object and then recreate dropped objects. See this [article by Mateusz Wenus](http://pretius.com/postgresql-stop-worrying-about-table-and-view-dependencies/) to learn, how to solve this problem. I enhanced that solution by adding handling of table and view rules. You can find my solution in script [postgres-handle-view-changes.sql](uploads/788f664087cefe0cf471efb05414fa4e/postgres-handle-view-changes.sql). It's battle tested by me. |
|
|
\ No newline at end of file |