notes/postgres/user.sql

40 lines
1.1 KiB
MySQL
Raw Normal View History

2019-03-30 02:28:55 -04:00
DROP USER IF EXISTS api;
2018-11-08 23:48:56 -05:00
2018-11-09 12:37:19 -05:00
SET password_encryption = 'scram-sha-256';
2018-11-08 23:49:20 -05:00
2019-03-30 02:28:55 -04:00
CREATE ROLE api WITH
2018-11-08 23:48:56 -05:00
LOGIN
NOSUPERUSER
NOCREATEDB
NOCREATEROLE
INHERIT
NOREPLICATION
CONNECTION LIMIT -1
2019-03-30 02:28:55 -04:00
PASSWORD 'api';
2018-11-08 23:48:56 -05:00
--------------------grant--------------------------------------------------
2019-03-30 02:28:55 -04:00
GRANT USAGE ON SCHEMA lgdat TO api;
2018-11-08 23:48:56 -05:00
2019-03-30 02:28:55 -04:00
GRANT SELECT /*, UPDATE, INSERT, DELETE*/ ON ALL TABLES IN SCHEMA lgdat TO api;
2018-11-08 23:48:56 -05:00
2019-03-30 02:28:55 -04:00
GRANT USAGE ON ALL SEQUENCES IN SCHEMA lgdat TO api;
2018-11-08 23:48:56 -05:00
2019-03-30 02:28:55 -04:00
ALTER DEFAULT PRIVILEGES IN SCHEMA lgdat GRANT SELECT/*, UPDATE, INSERT, DELETE*/ ON TABLES TO api;
2018-11-08 23:48:56 -05:00
2019-03-30 02:28:55 -04:00
ALTER DEFAULT PRIVILEGES IN SCHEMA lgdat GRANT USAGE ON SEQUENCES TO api;
2018-11-08 23:48:56 -05:00
---------------------------revoke---------------------------------------
2019-03-30 02:28:55 -04:00
REVOKE USAGE ON SCHEMA lgdat FROM api;
2018-11-08 23:48:56 -05:00
2019-03-30 02:28:55 -04:00
REVOKE USAGE ON SCHEMA lgdat FROM api;
2018-11-08 23:48:56 -05:00
2019-03-30 02:28:55 -04:00
REVOKE SELECT , UPDATE, INSERT, DELETE ON ALL TABLES IN SCHEMA lgdat FROM api;
2018-11-08 23:48:56 -05:00
2019-03-30 02:28:55 -04:00
REVOKE USAGE ON ALL SEQUENCES IN SCHEMA lgdat FROM api;
2018-11-08 23:48:56 -05:00
2019-03-30 02:28:55 -04:00
ALTER DEFAULT PRIVILEGES IN SCHEMA lgdat REVOKE SELECT, UPDATE, INSERT, DELETE ON TABLES FROM api;
2018-11-08 23:48:56 -05:00
2019-03-30 02:28:55 -04:00
ALTER DEFAULT PRIVILEGES IN SCHEMA lgdat REVOKE USAGE ON SEQUENCES FROM api;