views:

52

answers:

1

I'm the process of moving applications over from all in the public schema to each having their own schema. for each application, I have a small script that will create the schema and then create the tables,functions,etc... to that schema. Is there anyway to automatically add a newly created schema to the search_path? Currently, the only way I see is to find the users current path SHOW search_path; and then add the new schema to it SET search_path to xxx,yyy,zzz;

I would like some way to just say, append schema zzz to the users_search path. is this possible?

+1  A: 

Use the set_config() function like so:

SELECT set_config(
    'search_path',
    current_setting('search_path') || ',zzz',
    false
);
Theory