camper/revert/edit_campsite_type@v1.sql

35 lines
1.4 KiB
MySQL
Raw Normal View History

-- Deploy camper:edit_campsite_type to pg
-- requires: roles
-- requires: schema_camper
-- requires: campsite_type
-- requires: company
begin;
set search_path to camper, public;
drop function if exists edit_campsite_type(uuid, integer, text, text, text, text, text, text, integer, boolean, boolean);
create or replace function edit_campsite_type(slug uuid, media_id integer, name text, spiel text, info text, facilities text, description text, max_campers integer, dogs_allowed boolean, active boolean) returns uuid as
$$
update campsite_type
set name = edit_campsite_type.name
, spiel = xmlparse(content edit_campsite_type.spiel)
, description = xmlparse(content edit_campsite_type.description)
, info = xmlparse(content edit_campsite_type.info)
, facilities = xmlparse(content edit_campsite_type.facilities)
, media_id = coalesce(edit_campsite_type.media_id, campsite_type.media_id)
, max_campers = edit_campsite_type.max_campers
, dogs_allowed = edit_campsite_type.dogs_allowed
, active = edit_campsite_type.active
where slug = edit_campsite_type.slug
returning slug;
$$
language sql
;
revoke execute on function edit_campsite_type(uuid, integer, text, text, text, text, text, integer, boolean, boolean) from public;
grant execute on function edit_campsite_type(uuid, integer, text, text, text, text, text, integer, boolean, boolean) to admin;
commit;