-- Deploy camper:add_campsite_type to pg
-- requires: roles
-- requires: schema_camper
-- requires: campsite_type
-- requires: company

begin;

set search_path to camper, public;

drop function if exists add_campsite_type(integer, integer, text, text, text, text, text, integer, boolean);

create or replace function add_campsite_type(company integer, media_id integer, name text, spiel text, info text, facilities text, description text, additional_info text, max_campers integer, dogs_allowed boolean) returns uuid as
$$
	insert into campsite_type (company_id, media_id, name, spiel, info, facilities, description, additional_info, max_campers, dogs_allowed)
	values (company, media_id, name, xmlparse(content spiel), xmlparse(content info), xmlparse(content facilities), xmlparse(content description), xmlparse(content additional_info), max_campers, dogs_allowed)
	returning slug;
$$
	language sql
;

revoke execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, integer, boolean) from public;
grant execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, integer, boolean) to admin;

commit;
