Skip to content

Commit

Permalink
finalized scripts for pmt ownership transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
abimichel authored Jul 9, 2024
1 parent 27adb77 commit a7aa725
Showing 1 changed file with 68 additions and 4 deletions.
72 changes: 68 additions & 4 deletions permitting/ownership_transfer.sql
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
-- Steps to transfer ownership of tables (using 'ats_replication' schema as an example)
-- Steps to transfer ownership of tables

-- 1, as AMICHEL

-- 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
SELECT administration.create_proxy_account('fta_replication','');

SELECT administration.create_proxy_account('lexis_replication','');

SELECT administration.create_proxy_account('rrs_replication','');

-- 2, as each <app>_replication user

GRANT ats_replication TO ods_admin_user;

GRANT fta_replication TO ods_admin_user;

GRANT lexis_replication TO ods_admin_user;

GRANT rrs_replication TO ods_admin_user;

-- 3, as ods_admin_user

GRANT USAGE, CREATE ON SCHEMA ats_replication TO ats_replication;

DO $$DECLARE
table_name TEXT;
BEGIN
Expand All @@ -21,3 +37,51 @@ BEGIN
END$$;

GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA ods_data_management TO ats_replication;

GRANT USAGE, CREATE ON SCHEMA rrs_replication TO rrs_replication;

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

GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA ods_data_management TO rrs_replication;

GRANT USAGE, CREATE ON SCHEMA lexis_replication TO lexis_replication;

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

GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA ods_data_management TO lexis_replication;

GRANT USAGE, CREATE ON SCHEMA fta_replication TO fta_replication;

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

GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA ods_data_management TO fta_replication;

0 comments on commit a7aa725

Please sign in to comment.