Created
March 27, 2017 05:10
-
-
Save charly-vega/f2b62dcb9f6f66457b8923db09c0c896 to your computer and use it in GitHub Desktop.
This file contains 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
-- via https://wiki.postgresql.org/wiki/Shared_Database_Hosting | |
-- prep template1 | |
-- \c template1 <ROOTUSER> | |
REVOKE ALL ON DATABASE template1 FROM public; | |
GRANT ALL ON DATABASE template1 TO rds_superuser WITH GRANT OPTION; | |
REVOKE ALL ON SCHEMA public FROM public; | |
GRANT ALL ON SCHEMA public TO rds_superuser WITH GRANT OPTION; | |
CREATE LANGUAGE plpgsql; | |
-- new database + main use | |
-- \c template1 <ROOTUSER> | |
CREATE ROLE <DBNAME> NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT NOLOGIN; | |
CREATE ROLE <DBMAINUSER> NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN ENCRYPTED PASSWORD '<DBMAINUSERPASS>'; | |
GRANT <DBNAME> TO <DBMAINUSER>; | |
GRANT <DBMAINUSER> TO current_user; | |
CREATE DATABASE <DBNAME> WITH OWNER=<DBMAINUSER>; | |
REVOKE ALL ON DATABASE <DBNAME> FROM public; | |
GRANT ALL ON DATABASE <DBNAME> TO rds_superuser WITH GRANT OPTION; | |
REVOKE <DBMAINUSER> FROM current_user; | |
-- \c <DBNAME> <ROOTUSER> | |
GRANT ALL ON SCHEMA public TO <DBMAINUSER> WITH GRANT OPTION; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment