camper/deploy/edit_campsite_type_option@v...

26 lines
720 B
PL/PgSQL

-- Deploy camper:edit_campsite_type_option to pg
-- requires: roles
-- requires: schema_camper
-- requires: campsite_type_option
begin;
set search_path to camper, public;
create or replace function edit_campsite_type_option(option_id integer, name text, min integer, max integer) returns integer as
$$
update campsite_type_option
set name = edit_campsite_type_option.name
, range = int4range(min, max, '[]')
where campsite_type_option_id = option_id
returning campsite_type_option_id
;
$$
language sql
;
revoke execute on function edit_campsite_type_option(integer, text, integer, integer) from public;
grant execute on function edit_campsite_type_option(integer, text, integer, integer) to admin;
commit;