Skip to main content

Module views

Module views 

Source
Expand description

View / MV diff and OR-REPLACE compatibility.

§Body change detection

Two view bodies are considered identical when their canonical_hash bytes are equal. This avoids fragile text comparison and is already the canonical form produced by T4’s AST canonicalization pass and by the catalog reader.

§OR-REPLACE compatibility

Per Postgres’s CREATE OR REPLACE VIEW rules the new definition must:

  1. Have at least as many columns as the existing view.
  2. Keep the same column names at the same positions.
  3. Keep the same types at the same positions.

New columns may only be appended at the end.

or_replace_compatible encodes exactly these rules.

Functions§

diff_materialized_views
Diff target.materialized_views (live DB) against source.materialized_views (desired).
diff_views
Diff target.views (live DB) against source.views (desired).