I'm working in Postgres 9.4. I want to alter the type of a column in a table:
ALTER TABLE mytable ALTER COLUMN quantity TYPE integer;
But I get this:
ERROR: cannot alter type of a column used by a view or rule
This is because there are materialized views derived from that table.
Is there a way to temporarily disconnect the materialized views from this table so that I can update this table, then refresh the materialized views? (or if necessary, refresh them separately)
Or do I absolutely have to delete all the materialized views before I can change the column type?
UPDATE: It took three days to build the materialized views, and will take as long to rebuild them - which is why I'm asking this question. It's not trivial just to delete and recreate them.