Last active
November 5, 2024 22:51
-
-
Save matthewberryman/7689766b5f94a5499d8c to your computer and use it in GitHub Desktop.
Setup postgis in Amazon RDS
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
-- taken from http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.PostgreSQL.CommonDBATasks.html#Appendix.PostgreSQL.CommonDBATasks.PostGIS | |
create extension postgis; | |
create extension fuzzystrmatch; | |
create extension postgis_tiger_geocoder; | |
create extension postgis_topology; | |
alter schema tiger owner to rds_superuser; | |
alter schema tiger_data owner to rds_superuser; | |
alter schema topology owner to rds_superuser; | |
CREATE FUNCTION exec(text) returns text language plpgsql volatile AS $f$ BEGIN EXECUTE $1; RETURN $1; END; $f$; | |
SELECT exec('ALTER TABLE ' || quote_ident(s.nspname) || '.' || quote_ident(s.relname) || ' OWNER TO rds_superuser;') | |
FROM ( | |
SELECT nspname, relname | |
FROM pg_class c JOIN pg_namespace n ON (c.relnamespace = n.oid) | |
WHERE nspname in ('tiger','topology') AND | |
relkind IN ('r','S','v') ORDER BY relkind = 'S') | |
s; |
You can do those if required (though you may want to consider something tighter than public), however it works fine as is for my needs, and is a direct copy of http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.PostgreSQL.CommonDBATasks.html#Appendix.PostgreSQL.CommonDBATasks.PostGIS
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this is missing a couple of steps:
ALTER TABLE public.spatial_ref_sys OWNER TO rds_superuser;
GRANT SELECT, INSERT ON TABLE public.spatial_ref_sys TO public;`