-- Deploy camper:translate_surroundings_highlight to pg
-- requires: roles
-- requires: schema_camper
-- requires: surroundings_highlight_i18n

begin;

set search_path to camper, public;

create or replace function translate_surroundings_highlight(highlight_id integer, lang_tag text, name text, description text) returns void as
$$
	insert into surroundings_highlight_i18n (surroundings_highlight_id, lang_tag, name, description)
	values (highlight_id, lang_tag, name, xmlparse(content coalesce(description, '')))
	on conflict (surroundings_highlight_id, lang_tag) do update
	set name = excluded.name
	  , description = excluded.description
	;
$$
	language sql
;

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

commit;