This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or replace function fetch_schema_grants(_user text, _schema text) RETURNS TABLE(query text) as | |
$func$ | |
begin | |
RETURN QUERY select 'grant all on schema '||_schema||' to '||_user||';' union all select 'grant all on sequence '||sequence_schema||'.'||sequence_name||' to '||_user||';' from information_schema.sequences where sequence_schema=_schema union all select 'grant all on '||schemaname||'.'||tablename||' to '||_user||';' from pg_tables where schemaname=_schema; | |
end | |
$func$ language plpgsql; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION clone_schema(source_schema text, dest_schema text) RETURNS void AS | |
$$ | |
DECLARE | |
object text; | |
buffer text; | |
default_ text; | |
column_ text; | |
constraint_name_ text; | |
constraint_def_ text; |