-- Deploy camper:add_campsite_type_option to pg -- requires: roles -- requires: schema_camper -- requires: campsite_type_option -- requires: campsite_type -- requires: campsite_type_option__per_night begin; set search_path to camper, public; drop function if exists add_campsite_type_option(uuid, text, integer, integer); create or replace function add_campsite_type_option(type_slug uuid, name text, min integer, max integer, per_night boolean) returns integer as $$ insert into campsite_type_option (campsite_type_id, name, range, per_night) select campsite_type_id, add_campsite_type_option.name, int4range(min, max, '[]'), per_night from campsite_type where slug = type_slug returning campsite_type_option_id ; $$ language sql ; revoke execute on function add_campsite_type_option(uuid, text, integer, integer, boolean) from public; grant execute on function add_campsite_type_option(uuid, text, integer, integer, boolean) to admin; commit;