Skip to content

Commit

Permalink
add readonly user
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokant committed May 8, 2024
1 parent f4d6baf commit a29e0dd
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions db/migrations/20240508145816_readonly_user.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- migrate:up
DO
$do$
BEGIN
IF EXISTS (
SELECT FROM pg_catalog.pg_roles
WHERE rolname = 'readonly') THEN

RAISE NOTICE 'Role "readonly" already exists. Skipping.';
ELSE
create role "readonly" WITH LOGIN password 'readonly';
END IF;
END
$do$;

grant connect on database postgres to readonly;

GRANT USAGE ON SCHEMA public to readonly;

GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;

GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO readonly;


-- migrate:down

0 comments on commit a29e0dd

Please sign in to comment.