28 lines
634 B
PL/PgSQL
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;
|