title: PostgreSQL - Grant select on all tables (and future tables), in *all schemas*
body: <p>My database uses schemas to separate tenant-specific data for an application - each customer has a brand new schema created when they sign up to hold their data.</p>
  
  <p>This obviously means I don't know the name of all schemas ahead of time.</p>
  
  <p>I'd like to create a <code>readonly</code> role that has read access to <em>all</em> of these schemas, and those created in the future.</p>
  
  <p>All questions along these lines I've found require knowing the name of the schemas, e.g.:</p>
  
  <pre><code>-- Create a group
  CREATE ROLE readaccess;
  
  -- Grant access to existing tables
  GRANT USAGE ON SCHEMA a_given_schema TO readaccess;
  GRANT SELECT ON ALL TABLES IN SCHEMA a_given_schema TO readaccess;
  
  -- Grant access to future tables
  ALTER DEFAULT PRIVILEGES IN SCHEMA a_given_schema GRANT SELECT ON TABLES TO readaccess;
  
  -- Create user with password
  CREATE USER readonly WITH PASSWORD 'a_secret';
  GRANT readaccess TO readonly;
  </code></pre>
  
  <p>Is there a way to do something like this, but for all schemas in the future?</p>