camper/deploy/translate_legal_text.sql

26 lines
799 B
MySQL
Raw Normal View History

2023-12-22 01:23:18 +00:00
-- Deploy camper:translate_legal_text to pg
-- requires: roles
-- requires: schema_camper
-- requires: legal_text_i18n
begin;
set search_path to camper, public;
create or replace function translate_legal_text(company_id integer, slug text, lang_tag text, name text, content text) returns void as
$$
insert into legal_text_i18n (company_id, slug, lang_tag, name, content)
values (company_id, slug, lang_tag, coalesce(name, ''), xmlparse(content coalesce(content, '')))
on conflict (company_id, slug, lang_tag) do update
set name = excluded.name
, content = excluded.content
;
$$
language sql
;
revoke execute on function translate_legal_text(integer, text, text, text, text) from public;
grant execute on function translate_legal_text(integer, text, text, text, text) to admin;
commit;