You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add support for privileges in .pgschemaignore (#339) (#340)
* feat: add support for privileges and default_privileges in .pgschemaignore (#339)
Add [privileges] and [default_privileges] sections to .pgschemaignore that
filter grants by grantee role name patterns. This allows ignoring privilege
statements for roles that don't exist in the plan database (e.g., production
roles not available in embedded postgres).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix: address review feedback - check chdir error and add loader unit test
- Check os.Chdir error in TestIgnorePrivileges (consistency with existing tests)
- Add TestLoadIgnoreFile_PrivilegeSections unit test for TOML parsing of
[privileges] and [default_privileges] sections including negation patterns
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* docs: add privileges and default_privileges sections to ignore docs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
3.**Legacy Objects** - Ignore deprecated objects while maintaining new schema management
14
14
4.**Environment-Specific Objects** - Skip objects that exist only in certain environments
15
+
5.**Role-Specific Privileges** - Ignore grants to roles that don't exist in the plan database
15
16
16
17
## File Format
17
18
@@ -39,6 +40,12 @@ patterns = ["type_test_*"]
39
40
40
41
[sequences]
41
42
patterns = ["seq_temp_*", "seq_debug_*"]
43
+
44
+
[privileges]
45
+
patterns = ["deploy_bot", "admin_*"]
46
+
47
+
[default_privileges]
48
+
patterns = ["deploy_bot"]
42
49
```
43
50
44
51
## Pattern Syntax
@@ -79,6 +86,24 @@ patterns = [
79
86
80
87
This will ignore `test_data`, `test_results` but keep `test_core_config`, `test_core_settings`.
81
88
89
+
## Privileges
90
+
91
+
The `[privileges]` and `[default_privileges]` sections filter GRANT statements by **grantee role name**. This is useful when running `pgschema plan` with roles that don't exist in the plan database, or managing migrations across environments with different role configurations.
92
+
93
+
```toml
94
+
[privileges]
95
+
patterns = [
96
+
"deploy_bot", # Ignore all grants to deploy_bot
97
+
"admin_*", # Ignore grants to any admin_* role
98
+
"!admin_super"# But keep grants to admin_super
99
+
]
100
+
101
+
[default_privileges]
102
+
patterns = ["deploy_bot"] # Ignore ALTER DEFAULT PRIVILEGES for deploy_bot
103
+
```
104
+
105
+
The `[privileges]` section filters explicit grants (`GRANT ... TO role`), including column-level privileges. The `[default_privileges]` section filters `ALTER DEFAULT PRIVILEGES` statements.
106
+
82
107
## Triggers on Ignored Tables
83
108
84
109
Triggers can be defined on ignored tables. The table structure is not managed, but the trigger itself is.
0 commit comments