CREATE ROLE api LOGIN PASSWORD 'api-user';

GRANT SELECT, UPDATE, INSERT ON ALL TABLES IN SCHEMA "accounts" TO api;
GRANT USAGE ON SCHEMA "accounts" TO api;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA "accounts" TO api;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA accounts TO api;

GRANT SELECT, UPDATE, INSERT ON ALL TABLES IN SCHEMA "stats" TO api;
GRANT USAGE ON SCHEMA "stats" TO api;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA "stats" TO api;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA stats TO api;

GRANT SELECT, UPDATE, INSERT ON ALL TABLES IN SCHEMA "workouts" TO api;
GRANT USAGE ON SCHEMA "workouts" TO api;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA "workouts" TO api;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA workouts TO api;




CREATE ROLE hasura LOGIN PASSWORD 'hasura-user';

GRANT SELECT, UPDATE, INSERT ON ALL TABLES IN SCHEMA "accounts" TO hasura;
GRANT USAGE ON SCHEMA "accounts" TO hasura;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA "accounts" TO hasura;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA accounts TO hasura;

GRANT SELECT, UPDATE, INSERT ON ALL TABLES IN SCHEMA "stats" TO hasura;
GRANT USAGE ON SCHEMA "stats" TO hasura;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA "stats" TO hasura;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA stats TO hasura;

GRANT SELECT, UPDATE, INSERT ON ALL TABLES IN SCHEMA "workouts" TO hasura;
GRANT USAGE ON SCHEMA "workouts" TO hasura;
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA "workouts" TO hasura;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA workouts TO hasura;

GRANT CREATE ON DATABASE bodytrack TO hasura;
