How to create a view that does not prevent altering its underlying table? There's a certain reason why I can't drop and re-create the view every time I need to change a column type or add a new column. This is because the alter script is generated by our ORM when we change the complex type definition and there's a stable deployment procedure I don't want to change.
-- test initialization
drop view if exists test_dep_trk_v;
drop table if exists test_dep_trk;
create table test_dep_trk ( a varchar(10) );
-- the view MUST at all times contain all the columns of the table
create view test_dep_trk_v as select * from test_dep_trk;
-- this statement cannot be changed
alter table test_dep_trk alter column a type varchar(11);
.
ERROR: cannot alter type of a column used by a view or rule
DETAIL: rule _RETURN on view test_dep_trk_v depends on column "a"
SQL state: 0A000