-- Connect to DW from STAGING
drop user mapping for postgres SERVER click_dw;
-- DROP USER MAPPING

drop server click_dw;
-- DROP SERVER

drop extension postgres_fdw CASCADE;
-- DROP EXTENSION

CREATE EXTENSION postgres_fdw;

CREATE SERVER click_dw
        FOREIGN DATA WRAPPER postgres_fdw
        OPTIONS (host 'tcf-prod-auroradb-dw.ctbw9pug8nwp.af-south-1.rds.amazonaws.com', port '5432', dbname 'ClickDW', SSLMODE 'require');

CREATE USER MAPPING FOR postgres
        SERVER click_dw
        OPTIONS (user 'postgres', password '22GFPj4LF6WrlMoPjKec');     


-- Connect to STAGING from DW
drop user mapping for postgres SERVER click_staging;
-- DROP USER MAPPING

drop server click_staging;
-- DROP SERVER

drop extension postgres_fdw CASCADE;
-- DROP EXTENSION

CREATE EXTENSION postgres_fdw;

CREATE SERVER click_staging
        FOREIGN DATA WRAPPER postgres_fdw
        OPTIONS (host 'tcf-prod-auroradb-staging.ctbw9pug8nwp.af-south-1.rds.amazonaws.com', port '5432', dbname 'ClickSTAGING', SSLMODE 'require');

CREATE USER MAPPING FOR postgres
        SERVER click_staging
        OPTIONS (user 'postgres', password '22GFPj4LF6WrlMoPjKec');     