camper/deploy/translate_service.sql

26 lines
746 B
PL/PgSQL

-- Deploy camper:translate_service to pg
-- requires: roles
-- requires: schema_camper
-- requires: service_i18n
begin;
set search_path to camper, public;
create or replace function translate_service(service_id integer, lang_tag text, name text, description text) returns void as
$$
insert into service_i18n (service_id, lang_tag, name, description)
values (service_id, lang_tag, name, xmlparse(content coalesce(description, '')))
on conflict (service_id, lang_tag) do update
set name = excluded.name
, description = excluded.description
;
$$
language sql
;
revoke execute on function translate_service(integer, text, text, text) from public;
grant execute on function translate_service(integer, text, text, text) to admin;
commit;