camper/deploy/add_campsite_type@v0.sql

24 lines
973 B
PL/PgSQL

-- Deploy camper:add_campsite_type to pg
-- requires: roles
-- requires: schema_camper
-- requires: campsite_type
-- requires: company
begin;
set search_path to camper, public;
create or replace function add_campsite_type(company integer, media_id integer, name text, spiel text, info text, facilities text, description text, max_campers integer, dogs_allowed boolean) returns uuid as
$$
insert into campsite_type (company_id, media_id, name, spiel, info, facilities, description, max_campers, dogs_allowed)
values (company, media_id, name, xmlparse(content spiel), xmlparse(content info), xmlparse(content facilities), xmlparse(content description), max_campers, dogs_allowed)
returning slug;
$$
language sql
;
revoke execute on function add_campsite_type(integer, integer, text, text, text, text, text, integer, boolean) from public;
grant execute on function add_campsite_type(integer, integer, text, text, text, text, text, integer, boolean) to admin;
commit;