pg_viewctl
pg_viewctl · View dependency management and safe schema evolution utilities
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100901 | pg_viewctl | pg_viewctl | 0.1.0 | ADMIN | Unknown | Rust |
PostgreSQL · 13, 14, 15, 16, 17, 18
Usage
Sources:
pg_viewctl is an experimental pgrx extension for analyzing column-level view dependencies and generating ordered SQL plans for schema changes. It helps review the impact of replacing views, dropping or changing table columns, and renaming view columns; it does not automatically execute the generated migration.
Analyze Before Changing
Install version 0.1.0, inspect dependencies, and ask the extension to generate a plan:
Treat the returned rows as a draft migration. Review object ownership, security options, grants, comments, materialized-view refreshes, column references, locking, and data loss before copying SQL into a migration file.
Generators and Dependency Objects
generate_replace_viewplans dependent view/materialized-view teardown, target replacement, recreation, grants, and refreshes.generate_drop_columnplans dependencies around a table-column drop.generate_alter_typeplans a column type change and dependent recreation.generate_rename_view_columnplans a view-column rename and annotates dependent definitions that need manual edits.pgvc_column_dependenciesandget_column_dependenciesexpose column-level relationships, whilepgvc_dependency_orderproduces a recursive view order.
The generators return step, operation, sql, and target columns. A generated comment or manual-edit marker is a request for human editing, not executable proof that the migration is safe.
Deprecation Workflow
The extension can record a view column as deprecated before removal:
undeprecate_column removes the marker, and pgvc_deprecated_with_dependents summarizes remaining dependent views. This metadata is advisory and does not stop queries from using the column.
Boundaries
The official README labels the project work in progress and says the interface is likely to change. The control file marks it non-relocatable and does not require superuser or preload; source features target PostgreSQL 13 through 18, with PostgreSQL 18 as the default build.
Dependency discovery is based on PostgreSQL catalogs and stored view definitions. Dynamic SQL, application code, external consumers, function-body references, and dependencies not represented in those catalogs can be missed. Test every generated plan on a restored production-like database, execute it through normal change control, and keep a rollback path.