-- Deploy camper:order_campsite_type_features to pg
-- requires: schema_camper
-- requires: roles
-- requires: campsite_type_feature

begin;

set search_path to camper, public;

create or replace function order_campsite_type_features(positions integer[]) returns void as
$$
	update campsite_type_feature
	set position = cast(temp.position as integer)
	from unnest(positions) with ordinality as temp(feature_id, position)
	where campsite_type_feature_id = temp.feature_id
	;
$$
	language sql
;

revoke execute on function order_campsite_type_features(integer[]) from public;
grant execute on function order_campsite_type_features(integer[]) to admin;

commit;
