How do you automatically refresh a view in postgres?
I want to add a script which automatically refreshes all views after a database migration.
How could I achieve this?
I know REFRESH MATERIALIZED VIEW exists, but what if you just want to refresh the definition of a normal view?
As for why I want this, well I have a view like
CREATE OR REPLACE VIEW MyView
SELECT *
FROM MyTable
WHERE...
Now I add another column to MyTable in a new migration, but the view will not contain the new column since it was defined before the new migration.
So I wanted to add a deployment step where all the views definitions are refreshed on any new migration.
What can you recommend?