CREATE ROLE master_user;
CREATE ROLE readonly_user;
CREATE ROLE normal_user;
CREATE ROLE super_admin;
-- USER
CREATE USER master_user_01 WITH PASSWORD 'aaa';
CREATE USER readonly_user_01 WITH PASSWORD 'bbb';
CREATE USER normal_user_01 WITH PASSWORD 'ccc';
CREATE USER normal_user_02 WITH PASSWORD 'ddd';
CREATE USER super_admin_01 WITH PASSWORD 'eee';
-- GRANT USAGE
GRANT USAGE ON SCHEMA master TO master_user, readonly_user, normal_user;
GRANT USAGE ON SCHEMA transaction TO readonly_user, normal_user;
-- GRANT
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA master TO master_user;
GRANT SELECT ON ALL TABLES IN SCHEMA master TO readonly_user;
GRANT SELECT ON ALL TABLES IN SCHEMA transaction TO readonly_user;
GRANT SELECT ON ALL TABLES IN SCHEMA master TO normal_user;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA transaction TO normal_user;
-- GRANT SUPERUSER ROLE TO super_admin
GRANT rds_superuser TO super_admin;
-- GRANT ROLE TO USER
GRANT master_user TO master_user_01;
GRANT readonly_user TO readonly_user_01;
GRANT normal_user TO normal_user_01;
GRANT normal_user TO normal_user_02;
GRANT super_admin TO super_admin_01;
ALTER USER kekUser SET search_path = kek,public;