51 lines
1.1 KiB
MySQL
51 lines
1.1 KiB
MySQL
|
-- Deploy camper:remove_amenity to pg
|
||
|
-- requires: roles
|
||
|
-- requires: schema_camper
|
||
|
-- requires: amenity
|
||
|
-- requires: amenity_i18n
|
||
|
-- requires: amenity_carousel
|
||
|
-- requires: amenity_carousel_i18n
|
||
|
-- requires: amenity_feature
|
||
|
-- requires: amenity_feature_i18n
|
||
|
|
||
|
begin;
|
||
|
|
||
|
set search_path to camper, public;
|
||
|
|
||
|
create or replace function remove_amenity(amenity_id integer) returns void as
|
||
|
$$
|
||
|
delete from amenity_feature_i18n
|
||
|
where amenity_feature_id in (
|
||
|
select amenity_feature_id
|
||
|
from amenity_feature
|
||
|
where amenity_id = remove_amenity.amenity_id
|
||
|
);
|
||
|
|
||
|
delete from amenity_feature
|
||
|
where amenity_id = remove_amenity.amenity_id
|
||
|
;
|
||
|
|
||
|
delete from amenity_carousel_i18n
|
||
|
where amenity_id = remove_amenity.amenity_id
|
||
|
;
|
||
|
|
||
|
delete from amenity_carousel
|
||
|
where amenity_id = remove_amenity.amenity_id
|
||
|
;
|
||
|
|
||
|
delete from amenity_i18n
|
||
|
where amenity_id = remove_amenity.amenity_id
|
||
|
;
|
||
|
|
||
|
delete from amenity
|
||
|
where amenity_id = remove_amenity.amenity_id
|
||
|
;
|
||
|
$$
|
||
|
language sql
|
||
|
;
|
||
|
|
||
|
revoke execute on function remove_amenity(integer) from public;
|
||
|
grant execute on function remove_amenity(integer) to admin;
|
||
|
|
||
|
commit;
|