25 lines
584 B
PL/PgSQL
25 lines
584 B
PL/PgSQL
-- Deploy camper:order_campsite_types to pg
|
|
-- requires: schema_camper
|
|
-- requires: roles
|
|
-- requires: campsite_type
|
|
|
|
begin;
|
|
|
|
set search_path to camper, public;
|
|
|
|
create or replace function order_campsite_types(positions uuid[]) returns void as
|
|
$$
|
|
update campsite_type
|
|
set position = cast(temp.position as integer)
|
|
from unnest(positions) with ordinality as temp(slug, position)
|
|
where campsite_type.slug = temp.slug
|
|
;
|
|
$$
|
|
language sql
|
|
;
|
|
|
|
revoke execute on function order_campsite_types(uuid[]) from public;
|
|
grant execute on function order_campsite_types(uuid[]) to admin;
|
|
|
|
commit;
|