campingmontagut/deploy/add_amenity.sql
jordi fita mas eeaa3b415e Add amenities section and public page
This is more or less the same as the campsites, as public information
goes, but for buildings and other amenities that the camping provides
that are not campsites.
2024-01-27 22:51:41 +01:00

24 lines
640 B
PL/PgSQL

-- Deploy camper:add_amenity to pg
-- requires: roles
-- requires: schema_camper
-- requires: amenity
begin;
set search_path to camper, public;
create or replace function add_amenity(company_id integer, label text, name text, info1 text, info2 text) returns integer as
$$
insert into amenity (company_id, label, name, info1, info2)
values (company_id, label, name, xmlparse(content info1), xmlparse(content info2))
returning amenity_id
;
$$
language sql
;
revoke execute on function add_amenity(integer, text, text, text, text) from public;
grant execute on function add_amenity(integer, text, text, text, text) to admin;
commit;