camper/deploy/edit_campsite.sql

26 lines
700 B
MySQL
Raw Normal View History

-- 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(campsite_id integer, campsite_type integer, new_label text, active boolean) returns integer as
$$
update campsite
set label = edit_campsite.new_label
, campsite_type_id = edit_campsite.campsite_type
, active = edit_campsite.active
where campsite_id = edit_campsite.campsite_id
returning campsite_id;
$$
language sql
;
revoke execute on function edit_campsite(integer, integer, text, boolean) from public;
grant execute on function edit_campsite(integer, integer, text, boolean) to admin;
commit;