Skip to content

Commit 12cd548

Browse files
committed
Merge branch '8-docs-pg-roles' into 'dev'
Resolve "Add guide to create nologin role with read access to views" See merge request rplinternal/pgdd!7
2 parents b36c414 + 8f3c49b commit 12cd548

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.md

+40
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,46 @@ psql -d your_db
4242
CREATE EXTENSION pgdd;
4343
```
4444

45+
## Database Permissions
46+
47+
Create Read-only group role to assign to users
48+
that need access to query (read-only) the PgDD objects.
49+
50+
```
51+
CREATE ROLE dd_read WITH NOLOGIN;
52+
COMMENT ON ROLE dd_read IS 'Group role to grant read-only permissions to PgDD views.';
53+
54+
GRANT USAGE ON SCHEMA dd TO dd_read;
55+
GRANT SELECT ON ALL TABLES IN SCHEMA dd TO dd_read;
56+
ALTER DEFAULT PRIVILEGES IN SCHEMA dd GRANT SELECT ON TABLES TO dd_read;
57+
```
58+
59+
Access can now be granted to other users using:
60+
61+
```
62+
GRANT dd_read TO <your_login_user>;
63+
```
64+
65+
For read-write access.
66+
67+
68+
```
69+
CREATE ROLE dd_readwrite WITH NOLOGIN;
70+
COMMENT ON ROLE dd_readwrite IS 'Group role to grant write permissions to PgDD objects.';
71+
72+
GRANT dd_read TO dd_readwrite;
73+
74+
GRANT INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA dd TO dd_readwrite;
75+
ALTER DEFAULT PRIVILEGES IN SCHEMA dd GRANT INSERT, UPDATE, DELETE ON TABLES TO dd_readwrite;
76+
```
77+
78+
This access can be granted using:
79+
80+
```
81+
GRANT dd_readwrite TO <your_login_user>;
82+
```
83+
84+
4585
## Use Data Dictionary
4686

4787
Connect to your database using your favorite SQL client. This

0 commit comments

Comments
 (0)