25 lines
611 B
PL/PgSQL
25 lines
611 B
PL/PgSQL
-- Deploy camper:current_company_id to pg
|
|
-- requires: roles
|
|
-- requires: schema_camper
|
|
|
|
begin;
|
|
|
|
set search_path to camper;
|
|
|
|
create or replace function current_company_id() returns integer as
|
|
$$
|
|
select current_setting('request.company.id', true)::integer;
|
|
$$
|
|
language sql
|
|
stable;
|
|
|
|
comment on function current_company_id() is
|
|
'Returns the ID of the current company';
|
|
|
|
revoke execute on function current_company_id() from public;
|
|
grant execute on function current_company_id() to guest;
|
|
grant execute on function current_company_id() to employee;
|
|
grant execute on function current_company_id() to admin;
|
|
|
|
commit;
|