Skip to content

Instantly share code, notes, and snippets.

@Sillson
Created April 7, 2017 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sillson/19234a878b3f36e1800aea24ac5348b1 to your computer and use it in GitHub Desktop.
Save Sillson/19234a878b3f36e1800aea24ac5348b1 to your computer and use it in GitHub Desktop.
drop foreign schema and reimport
do
$$
declare
l_rec record;
begin
for l_rec in (select foreign_table_schema, foreign_table_name
from information_schema.foreign_tables) loop
execute format('drop foreign table %I.%I cascade', l_rec.foreign_table_schema, l_rec.foreign_table_name);
end loop;
end;
$$
IMPORT FOREIGN SCHEMA public
EXCEPT ( ar_internal_metadata, g5_authenticatable_roles, g5_authenticatable_users, job_logs, schema_migrations )
FROM SERVER \"#{ENV['DW_DBNAME']}\"
INTO public;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment