Skip to content

Conversation

@pyramation
Copy link
Contributor

@pyramation pyramation commented Jan 23, 2026

feat: add view tables to metaschema-schema

Summary

Upstream view system tables from constructive-db PR #421 to the shared pgpm-modules package. This adds four new tables to support the views infrastructure:

  • view: Main view definition table with schema reference, view_type (ViewTableProjection, ViewJoinedTables, ViewComposite, etc.), JSONB data for query configuration, and optional filter using Authz* node types
  • view_table: Junction table linking views to their joined tables for referential integrity (used by ViewJoinedTables)
  • view_grant: View-level permission grants (role, privilege, with_grant_option)
  • view_rule: DO INSTEAD rules for views (e.g., read-only enforcement)

The view.table_id is intentionally nullable to support ViewComposite which doesn't have a primary table reference.

Updates since last revision

Updated metaschema-modules snapshot tests to reflect increased constraint counts. The new view tables have foreign keys to metaschema_public.database, schema, and table, which increases the FK constraint counts in the cross-schema queries used by the tests.

Review & Testing Checklist for Human

  • Verify the pgpm.plan dependency order is correct (view must come before view_table, view_grant, view_rule)
  • Confirm the table structures match what's expected in constructive-db PR #421
  • Check that foreign key constraints reference the correct tables (schema, table, database)

Notes

This is a schema-only package. The tables have been tested in constructive-db PR #421 which uses this package as a dependency.

Requested by: Dan Lynch (@pyramation)
Link to Devin run: https://app.devin.ai/sessions/e705631c4cfd49e1bd051bf80c7f84a3

Add view, view_grant, view_rule, and view_table tables to support
the views system infrastructure. These tables enable:
- view: Main view definition with schema, name, view_type, and data
- view_table: Junction table linking views to their referenced tables
- view_grant: View-level permissions
- view_rule: View rules for triggers/actions

Upstream from constructive-db PR #421.
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

The view tables added to metaschema-schema have foreign keys to
metaschema_public.database, schema, and table, which increases
the constraint counts in the metaschema-modules tests.
@pyramation pyramation merged commit 4bb3567 into main Jan 23, 2026
22 checks passed
@pyramation pyramation deleted the devin/1769168431-upstream-view-tables branch January 23, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants