camper/deploy/translate_campsite_type@v0.sql

30 lines
1.3 KiB
MySQL
Raw Normal View History

-- Deploy camper:translate_campsite_type to pg
-- requires: roles
-- requires: schema_camper
-- requires: campsite_type_i18n
begin;
set search_path to camper, public;
create or replace function translate_campsite_type (slug uuid, lang_tag text, name text, spiel text, info text, facilities text, description text) returns void as
$$
insert into campsite_type_i18n (campsite_type_id, lang_tag, name, spiel, info, facilities, description)
select campsite_type_id, translate_campsite_type.lang_tag, translate_campsite_type.name, xmlparse(content coalesce(translate_campsite_type.spiel, '')), xmlparse(content coalesce(translate_campsite_type.info, '')), xmlparse(content coalesce(translate_campsite_type.facilities, '')), xmlparse(content coalesce(translate_campsite_type.description, ''))
from campsite_type
where slug = translate_campsite_type.slug
on conflict (campsite_type_id, lang_tag) do update
set name = excluded.name
, spiel = excluded.spiel
, info = excluded.info
, facilities = excluded.facilities
, description = excluded.description
$$
language sql
;
revoke execute on function translate_campsite_type (uuid, text, text, text, text, text, text) from public;
grant execute on function translate_campsite_type(uuid, text, text, text, text, text, text) to admin;
commit;