2023-08-04 17:59:58 +00:00
|
|
|
-- Deploy camper:add_campsite_type to pg
|
|
|
|
-- requires: roles
|
|
|
|
-- requires: schema_camper
|
|
|
|
-- requires: campsite_type
|
|
|
|
-- requires: company
|
2024-01-29 02:38:11 +00:00
|
|
|
-- requires: campsite_type__check_in_out
|
|
|
|
-- requires: campsite_type__overflow_allowed
|
|
|
|
-- requires: campsite_type__ask_zone_preferences
|
2023-08-04 17:59:58 +00:00
|
|
|
|
|
|
|
begin;
|
|
|
|
|
|
|
|
set search_path to camper, public;
|
|
|
|
|
2024-01-31 22:06:45 +00:00
|
|
|
drop function if exists add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, boolean, boolean, boolean);
|
2024-01-14 23:28:34 +00:00
|
|
|
|
Add campsite_type_pet_cost relation to hold price of dogs in campsites
It is a separate relation, instead of having a field in campsite_type,
because not all campsite types allow dogs. I could have added a new
field to campsite_type, but then its values it would be meaningless for
campsites that do not allow dogs, and a nullable field is not a valid
solution because NULL means “unknown”, but we **do** know the price —
none.
A separate relation encodes the same information without ambiguities nor
null values, and, in fact, removed the dogs_allowed field from
campsite_type to prevent erroneous status, such as a campsite type that
allows dogs without having a cost — even if the cost is zero, it has to
be added to the new relation.
2024-02-10 05:18:30 +00:00
|
|
|
create or replace function add_campsite_type(company integer, media_id integer, name text, spiel text, info text, facilities text, description text, additional_info text, check_in text, check_out text, max_campers integer, bookable_nights int4range, overflow_allowed boolean, ask_zone_preferences boolean) returns uuid as
|
2023-08-04 17:59:58 +00:00
|
|
|
$$
|
Add campsite_type_pet_cost relation to hold price of dogs in campsites
It is a separate relation, instead of having a field in campsite_type,
because not all campsite types allow dogs. I could have added a new
field to campsite_type, but then its values it would be meaningless for
campsites that do not allow dogs, and a nullable field is not a valid
solution because NULL means “unknown”, but we **do** know the price —
none.
A separate relation encodes the same information without ambiguities nor
null values, and, in fact, removed the dogs_allowed field from
campsite_type to prevent erroneous status, such as a campsite type that
allows dogs without having a cost — even if the cost is zero, it has to
be added to the new relation.
2024-02-10 05:18:30 +00:00
|
|
|
insert into campsite_type (company_id, media_id, name, spiel, info, facilities, description, additional_info, check_in, check_out, max_campers, bookable_nights, overflow_allowed, ask_zone_preferences)
|
|
|
|
values (company, media_id, name, xmlparse(content spiel), xmlparse(content info), xmlparse(content facilities), xmlparse(content description), xmlparse(content additional_info), check_in, check_out, max_campers, bookable_nights, overflow_allowed, ask_zone_preferences)
|
2023-08-04 17:59:58 +00:00
|
|
|
returning slug;
|
|
|
|
$$
|
|
|
|
language sql
|
|
|
|
;
|
|
|
|
|
Add campsite_type_pet_cost relation to hold price of dogs in campsites
It is a separate relation, instead of having a field in campsite_type,
because not all campsite types allow dogs. I could have added a new
field to campsite_type, but then its values it would be meaningless for
campsites that do not allow dogs, and a nullable field is not a valid
solution because NULL means “unknown”, but we **do** know the price —
none.
A separate relation encodes the same information without ambiguities nor
null values, and, in fact, removed the dogs_allowed field from
campsite_type to prevent erroneous status, such as a campsite type that
allows dogs without having a cost — even if the cost is zero, it has to
be added to the new relation.
2024-02-10 05:18:30 +00:00
|
|
|
revoke execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, int4range, boolean, boolean) from public;
|
|
|
|
grant execute on function add_campsite_type(integer, integer, text, text, text, text, text, text, text, text, integer, int4range, boolean, boolean) to admin;
|
2023-08-04 17:59:58 +00:00
|
|
|
|
|
|
|
commit;
|