|
| 1 | +/* |
| 2 | +#################### |
| 3 | +Add generation plants groups |
| 4 | +
|
| 5 | +Date applied: |
| 6 | +Description: |
| 7 | +This script adds the option to specify generation plant groups. |
| 8 | +The generation groups are specified in the table generation_plant_group. |
| 9 | +Plants are assigned to a group by adding them to the many-to-many table generation_plant_group_member. |
| 10 | +Groups are assigned to a generation_plant_scenario_id by specifying them in generation_plant_scenario_group_member |
| 11 | +################# |
| 12 | +*/ |
| 13 | + |
| 14 | +CREATE TABLE switch.generation_plant_group |
| 15 | +( |
| 16 | + generation_plant_group_id serial NOT NULL, |
| 17 | + description text NOT NULL, |
| 18 | + name character varying(30) NOT NULL, |
| 19 | + PRIMARY KEY (generation_plant_group_id) |
| 20 | +); |
| 21 | + |
| 22 | +COMMENT ON TABLE switch.generation_plant_group |
| 23 | + IS 'This table specifies all the generation plant groups. Every group has a set of generation plants (see generation_plant_group_member). Groups can be assigned to a generation_plant_scenario (see generation_plant_scenario_group_member).'; |
| 24 | + |
| 25 | +CREATE TABLE switch.generation_plant_group_member |
| 26 | +( |
| 27 | + generation_plant_group_id integer, |
| 28 | + generation_plant_id integer, |
| 29 | + PRIMARY KEY (generation_plant_group_id, generation_plant_id) |
| 30 | +); |
| 31 | + |
| 32 | +ALTER TABLE switch.generation_plant_group_member |
| 33 | + ADD CONSTRAINT generation_plant_group_member_group_id_fkey |
| 34 | + FOREIGN KEY (generation_plant_group_id) |
| 35 | + REFERENCES switch.generation_plant_group (generation_plant_group_id); |
| 36 | + |
| 37 | +ALTER TABLE switch.generation_plant_group_member |
| 38 | + ADD CONSTRAINT generation_plant_group_member_generation_plant_id_fkey |
| 39 | + FOREIGN KEY (generation_plant_id) |
| 40 | + REFERENCES switch.generation_plant (generation_plant_id); |
| 41 | + |
| 42 | +COMMENT ON TABLE switch.generation_plant_group_member |
| 43 | + IS 'This table is a many-to-many table that specifies the generation plants that are associated with a generation group.'; |
| 44 | + |
| 45 | +CREATE TABLE switch.generation_plant_scenario_group_member |
| 46 | +( |
| 47 | + generation_plant_scenario_id integer, |
| 48 | + generation_plant_group_id integer, |
| 49 | + PRIMARY KEY (generation_plant_scenario_id, generation_plant_group_id) |
| 50 | +); |
| 51 | + |
| 52 | +ALTER TABLE switch.generation_plant_scenario_group_member |
| 53 | + ADD CONSTRAINT generation_plant_scenario_group_member_scenario_id_fkey |
| 54 | + FOREIGN KEY (generation_plant_scenario_id) |
| 55 | + REFERENCES switch.generation_plant_scenario (generation_plant_scenario_id); |
| 56 | + |
| 57 | +ALTER TABLE switch.generation_plant_scenario_group_member |
| 58 | + ADD CONSTRAINT generation_plant_scenario_group_member_group_id_fkey |
| 59 | + FOREIGN KEY (generation_plant_group_id) |
| 60 | + REFERENCES switch.generation_plant_group (generation_plant_group_id); |
| 61 | + |
| 62 | +COMMENT ON TABLE switch.generation_plant_scenario_group_member |
| 63 | + IS 'This table is a many-to-many table that specifies which generation plant groups belong to which generation plant scenarios'; |
0 commit comments