jordi fita mas 5d0861824a 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 camper.

Closes #1
2023-07-22 01:59:12 +02:00

29 lines
496 B
PL/PgSQL

-- Deploy camper:roles to pg
begin;
do
$$
declare
role name;
roles name[] := array ['guest', 'employee', '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 employee to authenticator;
grant admin to authenticator;
commit;