Skip to content

Dynamically loading pgrst.db_schemas in cloud hosted environments for non super users #2552

Answered by steve-chavez
akshaysasidrn asked this question in Q&A
Discussion options

You must be logged in to vote

@thomasjungblut Some options for the pre-config:

  1. If your dynamic schemas names have some sort of prefix, like tenant_, you could do:
select 
  set_config('pgrst.db_schemas', string_agg(nspname, ','), true) 
from pg_namespace 
where nspname like 'tenant_%';

-- then reload each time you create a new schema
NOTIFY pgrst, 'reload config';
  1. If there's no name pattern but they're created with a particular role, like CREATE SCHEMA mine AUTHORIZATION joe:
select 
  set_config('pgrst.db_schemas', string_agg(nspname, ','), true) 
from pg_namespace 
where nspowner = 'joe'::regrole;

-- then reload each time you create a new schema
NOTIFY pgrst, 'reload config';
  1. Otherwise, you might need to crea…

Replies: 2 comments 12 replies

Comment options

You must be logged in to vote
1 reply
@akshaysasidrn
Comment options

Comment options

You must be logged in to vote
11 replies
@thomasjungblut
Comment options

@steve-chavez
Comment options

@thomasjungblut
Comment options

@steve-chavez
Comment options

Answer selected by wolfgangwalther
@thomasjungblut
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants