-- Deploy camper:translate_surroundings_ad to pg
-- requires: roles
-- requires: schema_camper
-- requires: surroundings_ad_i18n

begin;

set search_path to camper, public;

create or replace function translate_surroundings_ad(company_id integer, lang_tag text, title text, anchor text) returns void as
$$
	insert into surroundings_ad_i18n (company_id, lang_tag, title, anchor)
	values (company_id, lang_tag, title, anchor)
	on conflict (company_id, lang_tag)
	do update
	set title = excluded.title
	  , anchor = excluded.anchor
	;
$$
	language sql
;

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

commit;
