-- Deploy camper:order_surroundings_highlights to pg
-- requires: roles
-- requires: schema_camper
-- requires: surroundings_highlight

begin;

set search_path to camper, public;

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

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

commit;