camper/deploy/translate_amenity_feature.sql

25 lines
725 B
MySQL
Raw Normal View History

-- Deploy camper:translate_amenity_feature to pg
-- requires: roles
-- requires: schema_camper
-- requires: amenity_feature_i18n
begin;
set search_path to camper, public;
create or replace function translate_amenity_feature(feature_id integer, lang_tag text, name text) returns void as
$$
insert into amenity_feature_i18n (amenity_feature_id, lang_tag, name)
values (feature_id, lang_tag, case trim(name) when '' then null else name end)
on conflict (amenity_feature_id, lang_tag) do update
set name = excluded.name
;
$$
language sql
;
revoke execute on function translate_amenity_feature(integer, text, text) from public;
grant execute on function translate_amenity_feature(integer, text, text) to admin;
commit;