postgres database user grants to query database owned by other user
Your app user should be created like this.
Create the user:
CREATE ROLE &quot;app&quot; WITH ENCRYPTED PASSWORD '${APP_PASSWORD}' LOGIN;

Run this on mydb database.
Grant Connect to DB:
GRANT CONNECT ON DATABASE mydb to app; 

Grant Usage:
GRANT USAGE ON ALL SEQUENCES IN SCHEMA public TO &quot;app&quot;;
GRANT USAGE ON ALL TABLES IN SCHEMA public TO &quot;app&quot;;

Grant Other privileges:
GRANT SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES ON ALL TABLES IN SCHEMA public TO &quot;app&quot;;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO &quot;app&quot;;