Postgres roles and users - permission denied for table
From the documentation of ALTER DEFAULT PRIVILEGES
:
You can change default privileges only for objects that will be created by yourself or by roles that you are a member of. The privileges can be set globally (i.e., for all objects created in the current database), or just for objects created in specified schemas. Default privileges that are specified per-schema are added to whatever the global default privileges are for the particular object type.
Therefore the effect of running ALTER DEFAULT PRIVILEGES
as master
doesn't affect the default privileges of tables created by app_user1
.
To fix that you must execute the
ALTER DEFAULT PRIVILEGES IN SCHEMA myschema GRANT SELECT ON TABLES TO readonly;
as app_user1
too.