Skip to content

Commit

Permalink
add steps to transfer schema table ownership
Browse files Browse the repository at this point in the history
  • Loading branch information
abimichel committed Jun 27, 2024
1 parent 18e5773 commit 377190b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions permitting/ownership_transfer.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- Steps to transfer ownership of tables

-- 1, as amichel
SELECT administration.create_proxy_account('ats_replication','');
GRANT usage, create ON schema ats_replication TO ats_replication;

-- 2, as <app>_replication user
GRANT ats_replication TO ods_admin_user;

-- 3, as ods_admin_user
DO $$DECLARE
table_name TEXT;
BEGIN
FOR table_name IN
SELECT tablename
FROM pg_tables
WHERE schemaname = 'ats_replication'
LOOP
EXECUTE 'ALTER TABLE ats_replication.' || quote_ident(table_name) || ' OWNER TO ats_replication';
END LOOP;
END$$;

0 comments on commit 377190b

Please sign in to comment.