camper/deploy/order_cover_carousel.sql

25 lines
608 B
MySQL
Raw Normal View History

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