It turns out that, **this time**, at least, the way to compute the discount is not by “the more expensive”, but “the more expensive _in a given group_”. However, there are a couple of options, such as motorhome, that can be in different groups but only must be used once.
22 lines
423 B
PL/PgSQL
22 lines
423 B
PL/PgSQL
-- Deploy camper:acsi_option__option_group to pg
|
|
-- requires: acsi_option
|
|
|
|
begin;
|
|
|
|
set search_path to camper, public;
|
|
|
|
alter table acsi_option
|
|
add column option_group integer not null default 0
|
|
;
|
|
|
|
alter table acsi_option
|
|
drop constraint if exists acsi_option_pkey
|
|
;
|
|
|
|
alter table acsi_option
|
|
add primary key (campsite_type_id, campsite_type_option_id, option_group)
|
|
, alter column option_group drop default
|
|
;
|
|
|
|
commit;
|