26 lines
600 B
MySQL
26 lines
600 B
MySQL
|
-- Deploy camper:order_services to pg
|
||
|
-- requires: schema_camper
|
||
|
-- requires: roles
|
||
|
-- requires: service
|
||
|
-- requires: service__position
|
||
|
|
||
|
begin;
|
||
|
|
||
|
set search_path to camper, public;
|
||
|
|
||
|
create or replace function order_services(positions integer[]) returns void as
|
||
|
$$
|
||
|
update service
|
||
|
set position = cast(temp.position as integer)
|
||
|
from unnest(positions) with ordinality as temp(service_id, position)
|
||
|
where service.service_id = temp.service_id
|
||
|
;
|
||
|
$$
|
||
|
language sql
|
||
|
;
|
||
|
|
||
|
revoke execute on function order_services(integer[]) from public;
|
||
|
grant execute on function order_services(integer[]) to admin;
|
||
|
|
||
|
commit;
|