30 lines
940 B
PL/PgSQL
30 lines
940 B
PL/PgSQL
-- Deploy camper:edit_campsite_type_option to pg
|
|
-- requires: roles
|
|
-- requires: schema_camper
|
|
-- requires: campsite_type_option
|
|
-- requires: campsite_type_option__per_night
|
|
|
|
begin;
|
|
|
|
set search_path to camper, public;
|
|
|
|
drop function if exists edit_campsite_type_option(integer, text, integer, integer);
|
|
|
|
create or replace function edit_campsite_type_option(option_id integer, name text, min integer, max integer, per_night boolean) returns integer as
|
|
$$
|
|
update campsite_type_option
|
|
set name = edit_campsite_type_option.name
|
|
, range = int4range(min, max, '[]')
|
|
, per_night = edit_campsite_type_option.per_night
|
|
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, boolean) from public;
|
|
grant execute on function edit_campsite_type_option(integer, text, integer, integer, boolean) to admin;
|
|
|
|
commit;
|