Advanced user permissions
Managed Database for PostgreSQL and MySQL lets you manage the permissions of your database users from the Scaleway console, API, and CLI. The user permissions API covers most use cases, but has some limitations.
This page explains why a user permission can switch to Custom, and how to choose between managed and non-managed logical databases depending on the Structured Query Language (SQL) commands you need.
Before you start
To complete the following actions, you must have:
- A Scaleway account logged in to the console (External link)
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- A PostgreSQL or MySQL Database Instance
Custom permissions
When you create a user or update their permissions, you choose one of the following permission types for each logical database:
- None: No access to the database
- Read: Allow users to read tables and fields in a database
- Read/Write: Allow users to read/write content in databases
- All: Allow users to create schemas and tables in addition to Read/Write rights
After you set the permissions, the database can change. For example, someone creates new tables or installs an extension. For security purposes, Scaleway does not apply the user permissions for that database to new objects. The user permission for that database switches to Custom - the user keeps the rights they had when you last updated their permissions, but has no rights on the new objects.
The permission also switches to Custom when you make it more granular per object. For example, you give a user the Read permission on a database, then grant them read/write rights on a single table of that database.
Managed and non-managed logical databases
You can create a logical database in the following ways:
- From the Scaleway console, API, or CLI
- By running an SQL query directly on your Database Instance
Each option has advantages and drawbacks:
| Managed logical database | Non-managed logical database | |
|---|---|---|
| Creation method | Scaleway console, API, or CLI | SQL query on the Database Instance |
| User permissions API | Supported. See Set permissions for an existing user. | Not supported. You manage permissions manually with SQL queries. |
GRANT CONNECT and BYPASSRLS commands | Not allowed | Allowed |
On managed logical databases, you can get a result similar to GRANT CONNECT by giving the user the Read permission, then revoking the rights you do not need with a REVOKE statement.
BYPASSRLS is available on PostgreSQL only and lets a role bypass row-level security policies. For more information, see the PostgreSQL documentation about row security policies (External link).
Permissions for many databases and users
If your Database Instance has a large number of databases and users, the Scaleway console may have difficulty applying permission changes. For these use cases, use the Scaleway API (External link), the Scaleway CLI (External link), or Terraform (External link) instead.