camper/deploy/translate_location.sql

26 lines
824 B
MySQL
Raw Normal View History

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