camper/deploy/order_amenity_features.sql

25 lines
617 B
PL/PgSQL

-- Deploy camper:order_amenity_features to pg
-- requires: roles
-- requires: schema_camper
-- requires: amenity_feature
begin;
set search_path to camper, public;
create or replace function order_amenity_features(positions integer[]) returns void as
$$
update amenity_feature
set position = cast(temp.position as integer)
from unnest(positions) with ordinality as temp(feature_id, position)
where amenity_feature_id = temp.feature_id
;
$$
language sql
;
revoke execute on function order_amenity_features(integer[]) from public;
grant execute on function order_amenity_features(integer[]) to admin;
commit;