fix: add view privilege (GRANT/REVOKE) support to plan/apply#272
Open
dilame wants to merge 1 commit intostripe:mainfrom
Open
fix: add view privilege (GRANT/REVOKE) support to plan/apply#272dilame wants to merge 1 commit intostripe:mainfrom
dilame wants to merge 1 commit intostripe:mainfrom
Conversation
Fixes stripe#271 — pg-schema-diff plan previously ignored VIEW ACL diffs (both missing GRANT and missing REVOKE), while table privileges worked correctly. Root cause: views (relkind='v') were excluded from the privilege query, the View struct had no Privileges field, and the view diff pipeline had no privilege diffing logic. Changes: - Include views (relkind='v') in GetTablePrivileges query - Add Privileges field to View struct - Populate view privileges in fetchViews() - Wire privilege diffing into buildViewDiff/viewSQLGenerator - Add acceptance tests for view privilege scenarios
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #271
Summary
pg-schema-diff planignores VIEW ACL diffs — both missingGRANTand missingREVOKE. Table privileges work correctly, but views are completely excluded from the privilege pipeline.Root cause
Three layers:
internal/queries/queries.sql):GetTablePrivilegesfiltersrelkind IN ('r', 'p'), excluding views ('v')internal/schema/schema.go):Viewstruct has noPrivilegesfieldpkg/diff/view_sql_generator.go):viewDiffhas noprivilegesDiff,Add()emits no GRANTs,Alter()does not diff privilegesChanges
relkind = 'v') inGetTablePrivilegesqueryPrivileges []TablePrivilegetoViewstruct (reuses existing type)fetchViews()viafetchPrivileges()normalizeView()buildViewDiff()andviewSQLGenerator.{Add,Alter}Test plan
TestViewPrivilegeCasescovers grant, revoke, grant option, schema-qualified viewsGRANT/REVOKEfor views