campingmontagut/deploy/remove_amenity.sql
jordi fita mas eeaa3b415e Add amenities section and public page
This is more or less the same as the campsites, as public information
goes, but for buildings and other amenities that the camping provides
that are not campsites.
2024-01-27 22:51:41 +01:00

51 lines
1.1 KiB
PL/PgSQL

-- 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;