27 lines
824 B
PL/PgSQL
27 lines
824 B
PL/PgSQL
-- Deploy camper:translate_campsite to pg
|
|
-- requires: roles
|
|
-- requires: schema_camper
|
|
-- requires: campsite_i18n
|
|
|
|
begin;
|
|
|
|
set search_path to camper, public;
|
|
|
|
create or replace function translate_campsite(campsite_id integer, lang_tag text, info1 text, info2 text) returns void as
|
|
$$
|
|
insert into campsite_i18n (campsite_id, lang_tag, info1, info2)
|
|
values (campsite_id, lang_tag, case trim(info1) when '' then null else xmlparse(content info1) end, case trim(info2) when '' then null else xmlparse(content info2) end)
|
|
on conflict (campsite_id, lang_tag)
|
|
do update
|
|
set info1 = excluded.info1
|
|
, info2 = excluded.info2
|
|
;
|
|
$$
|
|
language sql
|
|
;
|
|
|
|
revoke execute on function translate_campsite(integer, text, text, text) from public;
|
|
grant execute on function translate_campsite(integer, text, text, text) to admin;
|
|
|
|
commit;
|