Conversation
Greptile SummaryFixed critical privilege ordering bug where transitioning from table-level to column-level privileges would leave users with no permissions. Root Cause
Solution
Testing
Confidence Score: 5/5
Important Files Changed
Last reviewed commit: a9a9bb8 |
There was a problem hiding this comment.
Pull request overview
Fixes privilege migration ordering so that when transitioning between table-level and column-level privileges, any necessary REVOKE executes before new GRANT statements (issue #324), preventing permissions from being unintentionally removed.
Changes:
- Reordered SQL generation so explicit privilege/column-privilege modifications are emitted before new privilege creates.
- Added two new regression test cases covering table→column privilege transitions and GRANT/REVOKE ordering in plan outputs.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/diff/diff.go | Reorders privilege/column-privilege modification emission relative to new grants to address #324. |
| testdata/diff/privilege/issue_324_modify_grant_to_column/plan.txt | Adds expected human plan output for the modify→column-grant transition case. |
| testdata/diff/privilege/issue_324_modify_grant_to_column/plan.sql | Adds expected SQL plan output (REVOKE before GRANT). |
| testdata/diff/privilege/issue_324_modify_grant_to_column/plan.json | Adds expected JSON plan output reflecting corrected step ordering. |
| testdata/diff/privilege/issue_324_modify_grant_to_column/old.sql | Adds old schema input for regression test. |
| testdata/diff/privilege/issue_324_modify_grant_to_column/new.sql | Adds new schema input for regression test. |
| testdata/diff/privilege/issue_324_modify_grant_to_column/diff.sql | Adds expected diff SQL for file-based diff tests. |
| testdata/diff/privilege/issue_324_grant_revoke_order/plan.txt | Adds expected human plan output for GRANT/REVOKE ordering case. |
| testdata/diff/privilege/issue_324_grant_revoke_order/plan.sql | Adds expected SQL plan output (REVOKE before GRANT). |
| testdata/diff/privilege/issue_324_grant_revoke_order/plan.json | Adds expected JSON plan output reflecting corrected step ordering. |
| testdata/diff/privilege/issue_324_grant_revoke_order/old.sql | Adds old schema input for regression test. |
| testdata/diff/privilege/issue_324_grant_revoke_order/new.sql | Adds new schema input for regression test. |
| testdata/diff/privilege/issue_324_grant_revoke_order/diff.sql | Adds expected diff SQL for file-based diff tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…olumn privileges (#324) When changing from table-level GRANT to column-level GRANT (e.g., GRANT UPDATE to GRANT UPDATE (col)), privilege modifications (containing REVOKEs) were emitted in Phase 3 (Modify) while new column grants were emitted in Phase 2 (Create), causing GRANTs to execute before REVOKEs and leaving the user with no permissions. Move all explicit privilege operations (both creates and modifications) to the end of generateModifySQL, after object modifications/recreations. This ensures: 1. DROP+CREATE'd objects (e.g., materialized views) don't wipe out privilege changes 2. REVOKEs from modifications execute before new GRANTs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
a9a9bb8 to
b40f7cb
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
GRANTto column-levelGRANT(e.g.,GRANT UPDATE→GRANT UPDATE (col)), the migration was emittingGRANTbeforeREVOKE, leaving the user with no permissionsFixes #324
Test plan
PGSCHEMA_TEST_FILTER="privilege/issue_324" go test -v ./internal/diff -run TestDiffFromFiles— two new test casesPGSCHEMA_TEST_FILTER="privilege/" go test -v ./internal/diff -run TestDiffFromFiles— all 13 privilege diff tests passPGSCHEMA_TEST_FILTER="privilege/" go test -v ./cmd -run TestPlanAndApply— all 13 privilege integration tests passPGSCHEMA_TEST_FILTER="default_privilege/" go test -v ./cmd -run TestPlanAndApply— all 9 default privilege tests pass🤖 Generated with Claude Code