41 lines
1.0 KiB
MySQL
41 lines
1.0 KiB
MySQL
|
-- Deploy camper:remove_campsite_carousel_slide to pg
|
||
|
-- requires: roles
|
||
|
-- requires: schema_camper
|
||
|
-- requires: campsite_carousel
|
||
|
-- requires: campsite_carousel_i18n
|
||
|
|
||
|
begin;
|
||
|
|
||
|
set search_path to camper, public;
|
||
|
|
||
|
create or replace function remove_campsite_carousel_slide(company_id integer, label text, media_id integer) returns void as
|
||
|
$$
|
||
|
declare
|
||
|
csid integer;
|
||
|
begin
|
||
|
select campsite_id
|
||
|
into csid
|
||
|
from campsite
|
||
|
where campsite.label = remove_campsite_carousel_slide.label
|
||
|
and campsite.company_id = remove_campsite_carousel_slide.company_id
|
||
|
;
|
||
|
|
||
|
delete from campsite_carousel_i18n
|
||
|
where campsite_id = csid
|
||
|
and campsite_carousel_i18n.media_id = remove_campsite_carousel_slide.media_id
|
||
|
;
|
||
|
|
||
|
delete from campsite_carousel
|
||
|
where campsite_id = csid
|
||
|
and campsite_carousel.media_id = remove_campsite_carousel_slide.media_id
|
||
|
;
|
||
|
end
|
||
|
$$
|
||
|
language plpgsql
|
||
|
;
|
||
|
|
||
|
revoke execute on function remove_campsite_carousel_slide(integer, text, integer) from public;
|
||
|
grant execute on function remove_campsite_carousel_slide(integer, text, integer) to admin;
|
||
|
|
||
|
commit;
|