-- Deploy camper:add_services_carousel_slide to pg
-- requires: roles
-- requires: schema_camper
-- requires: services_carousel

begin;

set search_path to camper, public;

drop function if exists add_services_carousel_slide(media_id integer, caption text);

create or replace function add_services_carousel_slide(media_id integer, caption text) returns void as
$$
	insert into services_carousel (media_id, caption)
	values (media_id, coalesce(caption, ''))
	on conflict (media_id) do update
	set caption = excluded.caption
	returning media_id
	;
$$
	language sql
;

revoke execute on function add_services_carousel_slide(integer, text) from public;
grant execute on function add_services_carousel_slide(integer, text) to admin;

commit;
