tipus/deploy/roles.sql
jordi fita mas 301195efac Add authentication relations, views, and functions for PostgreSQL
Most of them are exactly the same as we use for Numerus, but with the
main application schema changed to tipus.
2023-06-04 22:45:44 +02:00

28 lines
634 B
PL/PgSQL

-- Deploy tipus:roles to pg
begin;
do
$$
declare
role name;
roles name[] := array ['guest', 'publisher', 'admin', 'authenticator'];
begin
foreach role in array roles
loop
begin
execute 'create role ' || role || ' noinherit nologin';
exception
when duplicate_object then
raise notice '%, skipping', sqlerrm using errcode = sqlstate;
end;
end loop;
end
$$;
grant guest to authenticator;
grant publisher to authenticator;
grant admin to authenticator;
commit;