Skip to content

Commit f53cb95

Browse files
committed
Add an explanation of grants and privileges when using nais postgres prepare
1 parent 70eb366 commit f53cb95

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Grants and privileges
3+
tags: [postgres, cli, access, grants, privileges, explanation]
4+
---
5+
6+
When using the [`nais postgres prepare`](../how-to/personal-access.md#prerequisites) command, the user is granted some privileges in the database.
7+
8+
By default, the user is granted `SELECT` privileges on all tables and sequences in the default schema.
9+
10+
With the `--all-privs` flag, the user is granted `ALL` privileges on all tables and sequences in the default schema.
11+
In addition, the user is granted `CREATE` on the default schema.
12+
13+
This should be enough to allow most maintenance tasks, but if you need more privileges, you can usually grant yourself the needed privileges.
14+
If you find there are still some things you are unable to do, a common workaround is to make the changes via database-migration scripts (such as [Flyway](https://flywaydb.org/), [Liquibase](https://www.liquibase.org/), or [Alembic](https://alembic.sqlalchemy.org/)) that run as part of the application startup.
15+
Since these scripts are run by the application user, such scripts can also be used to grant additional privileges to personal users if needed.
16+
17+
Read more about PostgreSQL privileges in the official [PostgreSQL documentation](https://www.postgresql.org/docs/current/sql-grant.html).

docs/persistence/postgres/how-to/personal-access.md

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Databases should always be accessed using a personal account, and the access sho
5959
nais postgres prepare --all-privs <MYAPP>
6060
```
6161

62+
Read more about [Grants and Privileges](../explanations/grants-and-privileges.md).
63+
6264
## Granting temporary personal access
6365

6466
!!! check "Step 1. Create database IAM user"

0 commit comments

Comments
 (0)