B
B
Bovv2020-02-01 17:28:28
PostgreSQL
Bovv, 2020-02-01 17:28:28

Why doesn't it handle changing the default access rules at the schema level?

It is necessary for a specific role to set read-only rights (SELECT) for a specific schema in the database. After executing the command

GRANT SELECT ON ALL TABLES IN SCHEMA myschema TO myuser;

Everything works fine, but only for those tables that already exist. Tables that were created after these rights were assigned do not have access. To fix this issue, change the default settings:
ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT SELECT ON TABLES TO myuser;

ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT SELECT ON SEQUENCES TO myuser;

These commands do not give any result, the tables created in the future are still unreadable. However, if the access rights allow not only reading, but everything (ALL), the problem disappears.
ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT ALL ON TABLES TO myuser;

ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT ALL ON SEQUENCES TO myuser;


How to allow the user to read only tables that will be created in the future within the framework of this schema?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question