-- Deploy camper:setup_surroundings_ad to pg
-- requires: roles
-- requires: schema_camper
-- requires: surroundings_ad

begin;

set search_path to camper, public;

create or replace function setup_surroundings_ad(company integer, media_id integer, title text, anchor text, href uri) returns void as
$$
	insert into surroundings_ad (company_id, media_id, title, anchor, href)
	values (company, media_id, title, anchor, href)
	on conflict (company_id)
	do update
	set media_id = excluded.media_id
	  , title = excluded.title
	  , anchor = excluded.anchor
	  , href = excluded.href
	;
$$
	language sql
;

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

commit;