camper/deploy/order_seasons.sql

25 lines
535 B
PL/PgSQL

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