camper/deploy/edit_campsite.sql

26 lines
652 B
PL/PgSQL

-- Deploy camper:edit_campsite to pg
-- requires: roles
-- requires: schema_camper
-- requires: campsite
begin;
set search_path to camper, public;
create or replace function edit_campsite(slug uuid, campsite_type integer, label text, active boolean) returns uuid as
$$
update campsite
set label = edit_campsite.label
, campsite_type_id = edit_campsite.campsite_type
, active = edit_campsite.active
where slug = edit_campsite.slug
returning slug;
$$
language sql
;
revoke execute on function edit_campsite(uuid, integer, text, boolean) from public;
grant execute on function edit_campsite(uuid, integer, text, boolean) to admin;
commit;