Created
January 5, 2019 09:02
-
-
Save renatosuero/40ad1b6515b1a8df9cfc96d970402ee0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 public.migrate_schema(change text) | |
RETURNS integer AS | |
$BODY$ | |
DECLARE | |
v_schema text; | |
BEGIN | |
FOR v_schema IN | |
SELECT quote_ident(nspname) | |
FROM pg_namespace n | |
WHERE nspname !~~ 'pg_%' | |
AND nspname <> 'information_schema' | |
AND nspname <> 'public' | |
LOOP | |
EXECUTE 'SET LOCAL search_path = ' || v_schema; | |
EXECUTE change; | |
END LOOP; | |
return 1; | |
END; | |
$BODY$ | |
LANGUAGE plpgsql VOLATILE | |
COST 100; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment