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