camper/deploy/order_home_carousel.sql

25 lines
601 B
PL/PgSQL

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