diff --git a/03_qgep_db_dss.sql b/03_qgep_db_dss.sql index ce0e4bb9..4bb5e5c4 100644 --- a/03_qgep_db_dss.sql +++ b/03_qgep_db_dss.sql @@ -1,6 +1,7 @@ ------ This file generates the VSA-DSS database (Modul VSA-DSS) in en on QQIS ------ For questions etc. please contact Stefan Burckhardt stefan.burckhardt@sjib.ch ------- version 03.07.2017 21:26:28 / updated 29.3.2023 +------ version 03.07.2017 21:26:28 / updated 29.3.2023 / added DEFERRABLE INITIALLY DEFERRED 10.5.2024 + BEGIN; ------ CREATE SCHEMA qgep; @@ -3324,9 +3325,9 @@ FOR EACH ROW EXECUTE PROCEDURE ------- ------------ Relationships and Value Tables ----------- ; ALTER TABLE qgep_od.re_maintenance_event_wastewater_structure ADD COLUMN fk_wastewater_structure varchar (16); -ALTER TABLE qgep_od.re_maintenance_event_wastewater_structure ADD CONSTRAINT rel_maintenance_event_wastewater_structure_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.re_maintenance_event_wastewater_structure ADD CONSTRAINT rel_maintenance_event_wastewater_structure_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.re_maintenance_event_wastewater_structure ADD COLUMN fk_maintenance_event varchar (16); -ALTER TABLE qgep_od.re_maintenance_event_wastewater_structure ADD CONSTRAINT rel_maintenance_event_wastewater_structure_maintenance_event FOREIGN KEY (fk_maintenance_event) REFERENCES qgep_od.maintenance_event(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.re_maintenance_event_wastewater_structure ADD CONSTRAINT rel_maintenance_event_wastewater_structure_maintenance_event FOREIGN KEY (fk_maintenance_event) REFERENCES qgep_od.maintenance_event(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; --ALTER TABLE qgep_od.re_maintenance_event_wastewater_structure ADD COLUMN fk_wastewater_structure varchar (16); --ALTER TABLE qgep_od.re_maintenance_event_wastewater_structure ADD CONSTRAINT rel_maintenance_event_wastewater_structure_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON UPDATE CASCADE ON DELETE cascade; --ALTER TABLE qgep_od.re_maintenance_event_wastewater_structure ADD COLUMN fk_maintenance_event varchar (16); @@ -3342,7 +3343,7 @@ ALTER TABLE qgep_vl.symbol_plantype ADD CONSTRAINT pkey_qgep_vl_symbol_plantype_ REFERENCES qgep_vl.symbol_plantype (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.txt_symbol ADD COLUMN fk_wastewater_structure varchar (16); -ALTER TABLE qgep_od.txt_symbol ADD CONSTRAINT rel_symbol_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE cascade; +ALTER TABLE qgep_od.txt_symbol ADD CONSTRAINT rel_symbol_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.text_plantype () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.text_plantype ADD CONSTRAINT pkey_qgep_vl_text_plantype_code PRIMARY KEY (code); INSERT INTO qgep_vl.text_plantype (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (7844,7844,'pipeline_registry','Leitungskataster','cadastre_des_conduites_souterraines', 'catasto_delle_canalizzazioni', '', '', '', '', '', '', 'true'); @@ -3372,11 +3373,11 @@ ALTER TABLE qgep_vl.text_textvali ADD CONSTRAINT pkey_qgep_vl_text_textvali_code REFERENCES qgep_vl.text_textvali (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.txt_text ADD COLUMN fk_wastewater_structure varchar (16); -ALTER TABLE qgep_od.txt_text ADD CONSTRAINT rel_text_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE cascade; +ALTER TABLE qgep_od.txt_text ADD CONSTRAINT rel_text_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.txt_text ADD COLUMN fk_catchment_area varchar (16); -ALTER TABLE qgep_od.txt_text ADD CONSTRAINT rel_text_catchment_area FOREIGN KEY (fk_catchment_area) REFERENCES qgep_od.catchment_area(obj_id) ON DELETE cascade; +ALTER TABLE qgep_od.txt_text ADD CONSTRAINT rel_text_catchment_area FOREIGN KEY (fk_catchment_area) REFERENCES qgep_od.catchment_area(obj_id) ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.txt_text ADD COLUMN fk_reach varchar (16); -ALTER TABLE qgep_od.txt_text ADD CONSTRAINT rel_text_reach FOREIGN KEY (fk_reach) REFERENCES qgep_od.reach(obj_id) ON DELETE cascade; +ALTER TABLE qgep_od.txt_text ADD CONSTRAINT rel_text_reach FOREIGN KEY (fk_reach) REFERENCES qgep_od.reach(obj_id) ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.mutation_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.mutation_kind ADD CONSTRAINT pkey_qgep_vl_mutation_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.mutation_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5523,5523,'created','erstellt','cree', 'zzz_erstellt', '', '', '', '', '', '', 'true'); @@ -3385,7 +3386,7 @@ ALTER TABLE qgep_vl.mutation_kind ADD CONSTRAINT pkey_qgep_vl_mutation_kind_code ALTER TABLE qgep_od.mutation ADD CONSTRAINT fkey_vl_mutation_kind FOREIGN KEY (kind) REFERENCES qgep_vl.mutation_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.river ADD CONSTRAINT oorel_od_river_surface_water_bodies FOREIGN KEY (obj_id) REFERENCES qgep_od.surface_water_bodies(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.river ADD CONSTRAINT oorel_od_river_surface_water_bodies FOREIGN KEY (obj_id) REFERENCES qgep_od.surface_water_bodies(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.river_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.river_kind ADD CONSTRAINT pkey_qgep_vl_river_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.river_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3397,3397,'englacial_river','Gletscherbach','ruisseau_de_glacier', 'zzz_Gletscherbach', '', '', '', '', '', '', 'true'); @@ -3396,7 +3397,7 @@ ALTER TABLE qgep_vl.river_kind ADD CONSTRAINT pkey_qgep_vl_river_kind_code PRIMA ALTER TABLE qgep_od.river ADD CONSTRAINT fkey_vl_river_kind FOREIGN KEY (kind) REFERENCES qgep_vl.river_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.lake ADD CONSTRAINT oorel_od_lake_surface_water_bodies FOREIGN KEY (obj_id) REFERENCES qgep_od.surface_water_bodies(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.lake ADD CONSTRAINT oorel_od_lake_surface_water_bodies FOREIGN KEY (obj_id) REFERENCES qgep_od.surface_water_bodies(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.water_course_segment_algae_growth () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.water_course_segment_algae_growth ADD CONSTRAINT pkey_qgep_vl_water_course_segment_algae_growth_code PRIMARY KEY (code); INSERT INTO qgep_vl.water_course_segment_algae_growth (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2623,2623,'none_or_marginal','kein_gering','absent_faible', 'zzz_kein_gering', '', '', '', '', '', '', 'true'); @@ -3527,7 +3528,7 @@ ALTER TABLE qgep_vl.water_course_segment_width_variability ADD CONSTRAINT pkey_q REFERENCES qgep_vl.water_course_segment_width_variability (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.water_course_segment ADD COLUMN fk_watercourse varchar (16); -ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT rel_water_course_segment_watercourse FOREIGN KEY (fk_watercourse) REFERENCES qgep_od.river(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.water_course_segment ADD CONSTRAINT rel_water_course_segment_watercourse FOREIGN KEY (fk_watercourse) REFERENCES qgep_od.river(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.water_catchment_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.water_catchment_kind ADD CONSTRAINT pkey_qgep_vl_water_catchment_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.water_catchment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (24,24,'process_water','Brauchwasser','eau_industrielle', 'zzz_Brauchwasser', '', '', '', '', '', '', 'true'); @@ -3537,9 +3538,9 @@ ALTER TABLE qgep_vl.water_catchment_kind ADD CONSTRAINT pkey_qgep_vl_water_catch REFERENCES qgep_vl.water_catchment_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.water_catchment ADD COLUMN fk_aquifier varchar (16); -ALTER TABLE qgep_od.water_catchment ADD CONSTRAINT rel_water_catchment_aquifier FOREIGN KEY (fk_aquifier) REFERENCES qgep_od.aquifier(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.water_catchment ADD CONSTRAINT rel_water_catchment_aquifier FOREIGN KEY (fk_aquifier) REFERENCES qgep_od.aquifier(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.water_catchment ADD COLUMN fk_surface_water_bodies varchar (16); -ALTER TABLE qgep_od.water_catchment ADD CONSTRAINT rel_water_catchment_surface_water_bodies FOREIGN KEY (fk_surface_water_bodies) REFERENCES qgep_od.surface_water_bodies(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.water_catchment ADD CONSTRAINT rel_water_catchment_surface_water_bodies FOREIGN KEY (fk_surface_water_bodies) REFERENCES qgep_od.surface_water_bodies(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.river_bank_control_grade_of_river () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.river_bank_control_grade_of_river ADD CONSTRAINT pkey_qgep_vl_river_bank_control_grade_of_river_code PRIMARY KEY (code); INSERT INTO qgep_vl.river_bank_control_grade_of_river (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (341,341,'none','keine','nul', 'nessuno', 'inexistent', '', '', '', '', '', 'true'); @@ -3602,7 +3603,7 @@ ALTER TABLE qgep_vl.river_bank_vegetation ADD CONSTRAINT pkey_qgep_vl_river_bank REFERENCES qgep_vl.river_bank_vegetation (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.river_bank ADD COLUMN fk_water_course_segment varchar (16); -ALTER TABLE qgep_od.river_bank ADD CONSTRAINT rel_river_bank_water_course_segment FOREIGN KEY (fk_water_course_segment) REFERENCES qgep_od.water_course_segment(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.river_bank ADD CONSTRAINT rel_river_bank_water_course_segment FOREIGN KEY (fk_water_course_segment) REFERENCES qgep_od.water_course_segment(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.river_bed_control_grade_of_river () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.river_bed_control_grade_of_river ADD CONSTRAINT pkey_qgep_vl_river_bed_control_grade_of_river_code PRIMARY KEY (code); INSERT INTO qgep_vl.river_bed_control_grade_of_river (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (142,142,'none','keine','nul', 'nessuno', 'inexistent', '', '', '', '', '', 'true'); @@ -3635,7 +3636,7 @@ ALTER TABLE qgep_vl.river_bed_river_control_type ADD CONSTRAINT pkey_qgep_vl_riv REFERENCES qgep_vl.river_bed_river_control_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.river_bed ADD COLUMN fk_water_course_segment varchar (16); -ALTER TABLE qgep_od.river_bed ADD CONSTRAINT rel_river_bed_water_course_segment FOREIGN KEY (fk_water_course_segment) REFERENCES qgep_od.water_course_segment(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.river_bed ADD CONSTRAINT rel_river_bed_water_course_segment FOREIGN KEY (fk_water_course_segment) REFERENCES qgep_od.water_course_segment(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.sector_water_body_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.sector_water_body_kind ADD CONSTRAINT pkey_qgep_vl_sector_water_body_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.sector_water_body_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2657,2657,'waterbody','Gewaesser','lac_ou_cours_d_eau', 'zzz_Gewaesser', '', '', '', '', '', '', 'true'); @@ -3647,14 +3648,14 @@ ALTER TABLE qgep_vl.sector_water_body_kind ADD CONSTRAINT pkey_qgep_vl_sector_wa REFERENCES qgep_vl.sector_water_body_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.sector_water_body ADD COLUMN fk_surface_water_bodies varchar (16); -ALTER TABLE qgep_od.sector_water_body ADD CONSTRAINT rel_sector_water_body_surface_water_bodies FOREIGN KEY (fk_surface_water_bodies) REFERENCES qgep_od.surface_water_bodies(obj_id) ON UPDATE CASCADE ON DELETE cascade; -ALTER TABLE qgep_od.cooperative ADD CONSTRAINT oorel_od_cooperative_organisation FOREIGN KEY (obj_id) REFERENCES qgep_od.organisation(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE qgep_od.canton ADD CONSTRAINT oorel_od_canton_organisation FOREIGN KEY (obj_id) REFERENCES qgep_od.organisation(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE qgep_od.waste_water_association ADD CONSTRAINT oorel_od_waste_water_association_organisation FOREIGN KEY (obj_id) REFERENCES qgep_od.organisation(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE qgep_od.municipality ADD CONSTRAINT oorel_od_municipality_organisation FOREIGN KEY (obj_id) REFERENCES qgep_od.organisation(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE qgep_od.administrative_office ADD CONSTRAINT oorel_od_administrative_office_organisation FOREIGN KEY (obj_id) REFERENCES qgep_od.organisation(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE qgep_od.waste_water_treatment_plant ADD CONSTRAINT oorel_od_waste_water_treatment_plant_organisation FOREIGN KEY (obj_id) REFERENCES qgep_od.organisation(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE qgep_od.private ADD CONSTRAINT oorel_od_private_organisation FOREIGN KEY (obj_id) REFERENCES qgep_od.organisation(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.sector_water_body ADD CONSTRAINT rel_sector_water_body_surface_water_bodies FOREIGN KEY (fk_surface_water_bodies) REFERENCES qgep_od.surface_water_bodies(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.cooperative ADD CONSTRAINT oorel_od_cooperative_organisation FOREIGN KEY (obj_id) REFERENCES qgep_od.organisation(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.canton ADD CONSTRAINT oorel_od_canton_organisation FOREIGN KEY (obj_id) REFERENCES qgep_od.organisation(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.waste_water_association ADD CONSTRAINT oorel_od_waste_water_association_organisation FOREIGN KEY (obj_id) REFERENCES qgep_od.organisation(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.municipality ADD CONSTRAINT oorel_od_municipality_organisation FOREIGN KEY (obj_id) REFERENCES qgep_od.organisation(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.administrative_office ADD CONSTRAINT oorel_od_administrative_office_organisation FOREIGN KEY (obj_id) REFERENCES qgep_od.organisation(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.waste_water_treatment_plant ADD CONSTRAINT oorel_od_waste_water_treatment_plant_organisation FOREIGN KEY (obj_id) REFERENCES qgep_od.organisation(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.private ADD CONSTRAINT oorel_od_private_organisation FOREIGN KEY (obj_id) REFERENCES qgep_od.organisation(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.wastewater_structure_accessibility () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.wastewater_structure_accessibility ADD CONSTRAINT pkey_qgep_vl_wastewater_structure_accessibility_code PRIMARY KEY (code); INSERT INTO qgep_vl.wastewater_structure_accessibility (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3444,3444,'covered','ueberdeckt','couvert', 'coperto', 'capac', '', 'UED', 'CO', '', '', 'true'); @@ -3722,10 +3723,10 @@ ALTER TABLE qgep_vl.wastewater_structure_structure_condition ADD CONSTRAINT pkey REFERENCES qgep_vl.wastewater_structure_structure_condition (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.wastewater_structure ADD COLUMN fk_owner varchar (16); -ALTER TABLE qgep_od.wastewater_structure ADD CONSTRAINT rel_wastewater_structure_owner FOREIGN KEY (fk_owner) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.wastewater_structure ADD CONSTRAINT rel_wastewater_structure_owner FOREIGN KEY (fk_owner) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.wastewater_structure ADD COLUMN fk_operator varchar (16); -ALTER TABLE qgep_od.wastewater_structure ADD CONSTRAINT rel_wastewater_structure_operator FOREIGN KEY (fk_operator) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null; -ALTER TABLE qgep_od.channel ADD CONSTRAINT oorel_od_channel_wastewater_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.wastewater_structure ADD CONSTRAINT rel_wastewater_structure_operator FOREIGN KEY (fk_operator) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.channel ADD CONSTRAINT oorel_od_channel_wastewater_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.channel_bedding_encasement () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.channel_bedding_encasement ADD CONSTRAINT pkey_qgep_vl_channel_bedding_encasement_code PRIMARY KEY (code); INSERT INTO qgep_vl.channel_bedding_encasement (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5325,5325,'other','andere','autre', 'altro', 'altul', '', '', '', '', '', 'true'); @@ -3826,7 +3827,7 @@ ALTER TABLE qgep_vl.channel_usage_planned ADD CONSTRAINT pkey_qgep_vl_channel_us ALTER TABLE qgep_od.channel ADD CONSTRAINT fkey_vl_channel_usage_planned FOREIGN KEY (usage_planned) REFERENCES qgep_vl.channel_usage_planned (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.manhole ADD CONSTRAINT oorel_od_manhole_wastewater_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.manhole ADD CONSTRAINT oorel_od_manhole_wastewater_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.manhole_function () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.manhole_function ADD CONSTRAINT pkey_qgep_vl_manhole_function_code PRIMARY KEY (code); INSERT INTO qgep_vl.manhole_function (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4532,4532,'drop_structure','Absturzbauwerk','ouvrage_de_chute', 'manufatto_caduta', 'instalatie_picurare', 'DS', 'AK', 'OC', '', '', 'true'); @@ -3867,7 +3868,7 @@ ALTER TABLE qgep_vl.manhole_surface_inflow ADD CONSTRAINT pkey_qgep_vl_manhole_s ALTER TABLE qgep_od.manhole ADD CONSTRAINT fkey_vl_manhole_surface_inflow FOREIGN KEY (surface_inflow) REFERENCES qgep_vl.manhole_surface_inflow (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.discharge_point ADD CONSTRAINT oorel_od_discharge_point_wastewater_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.discharge_point ADD CONSTRAINT oorel_od_discharge_point_wastewater_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.discharge_point_relevance () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.discharge_point_relevance ADD CONSTRAINT pkey_qgep_vl_discharge_point_relevance_code PRIMARY KEY (code); INSERT INTO qgep_vl.discharge_point_relevance (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5580,5580,'relevant_for_water_course','gewaesserrelevant','pertinent_pour_milieu_recepteur', 'zzz_gewaesserrelevant', 'relevanta_pentru_mediul_receptor', '', '', '', '', '', 'true'); @@ -3876,8 +3877,8 @@ ALTER TABLE qgep_vl.discharge_point_relevance ADD CONSTRAINT pkey_qgep_vl_discha REFERENCES qgep_vl.discharge_point_relevance (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.discharge_point ADD COLUMN fk_sector_water_body varchar (16); -ALTER TABLE qgep_od.discharge_point ADD CONSTRAINT rel_discharge_point_sector_water_body FOREIGN KEY (fk_sector_water_body) REFERENCES qgep_od.sector_water_body(obj_id) ON UPDATE CASCADE ON DELETE set null; -ALTER TABLE qgep_od.special_structure ADD CONSTRAINT oorel_od_special_structure_wastewater_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.discharge_point ADD CONSTRAINT rel_discharge_point_sector_water_body FOREIGN KEY (fk_sector_water_body) REFERENCES qgep_od.sector_water_body(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.special_structure ADD CONSTRAINT oorel_od_special_structure_wastewater_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.special_structure_bypass () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.special_structure_bypass ADD CONSTRAINT pkey_qgep_vl_special_structure_bypass_code PRIMARY KEY (code); INSERT INTO qgep_vl.special_structure_bypass (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2682,2682,'inexistent','nicht_vorhanden','inexistant', 'zzz_nicht_vorhanden', 'inexistent', '', 'NV', 'IE', '', '', 'true'); @@ -3940,7 +3941,7 @@ ALTER TABLE qgep_vl.special_structure_stormwater_tank_arrangement ADD CONSTRAINT ALTER TABLE qgep_od.special_structure ADD CONSTRAINT fkey_vl_special_structure_stormwater_tank_arrangement FOREIGN KEY (stormwater_tank_arrangement) REFERENCES qgep_vl.special_structure_stormwater_tank_arrangement (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.infiltration_installation ADD CONSTRAINT oorel_od_infiltration_installation_wastewater_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.infiltration_installation ADD CONSTRAINT oorel_od_infiltration_installation_wastewater_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.infiltration_installation_defects () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.infiltration_installation_defects ADD CONSTRAINT pkey_qgep_vl_infiltration_installation_defects_code PRIMARY KEY (code); INSERT INTO qgep_vl.infiltration_installation_defects (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5361,5361,'none','keine','aucunes', 'nessuno', 'inexistente', '', 'K', 'AN', '', '', 'true'); @@ -4009,8 +4010,8 @@ ALTER TABLE qgep_vl.infiltration_installation_watertightness ADD CONSTRAINT pkey REFERENCES qgep_vl.infiltration_installation_watertightness (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.infiltration_installation ADD COLUMN fk_aquifier varchar (16); -ALTER TABLE qgep_od.infiltration_installation ADD CONSTRAINT rel_infiltration_installation_aquifier FOREIGN KEY (fk_aquifier) REFERENCES qgep_od.aquifier(obj_id) ON UPDATE CASCADE ON DELETE set null; -ALTER TABLE qgep_od.wwtp_structure ADD CONSTRAINT oorel_od_wwtp_structure_wastewater_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.infiltration_installation ADD CONSTRAINT rel_infiltration_installation_aquifier FOREIGN KEY (fk_aquifier) REFERENCES qgep_od.aquifier(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.wwtp_structure ADD CONSTRAINT oorel_od_wwtp_structure_wastewater_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.wwtp_structure_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.wwtp_structure_kind ADD CONSTRAINT pkey_qgep_vl_wwtp_structure_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.wwtp_structure_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (331,331,'sedimentation_basin','Absetzbecken','bassin_de_decantation', 'zzz_Absetzbecken', '', '', '', '', '', '', 'true'); @@ -4047,8 +4048,8 @@ ALTER TABLE qgep_vl.maintenance_event_status ADD CONSTRAINT pkey_qgep_vl_mainten REFERENCES qgep_vl.maintenance_event_status (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.maintenance_event ADD COLUMN fk_operating_company varchar (16); -ALTER TABLE qgep_od.maintenance_event ADD CONSTRAINT rel_maintenance_event_operating_company FOREIGN KEY (fk_operating_company) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null; -ALTER TABLE qgep_od.planning_zone ADD CONSTRAINT oorel_od_planning_zone_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.maintenance_event ADD CONSTRAINT rel_maintenance_event_operating_company FOREIGN KEY (fk_operating_company) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.planning_zone ADD CONSTRAINT oorel_od_planning_zone_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.planning_zone_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.planning_zone_kind ADD CONSTRAINT pkey_qgep_vl_planning_zone_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.planning_zone_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2990,2990,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); @@ -4060,7 +4061,7 @@ ALTER TABLE qgep_vl.planning_zone_kind ADD CONSTRAINT pkey_qgep_vl_planning_zone ALTER TABLE qgep_od.planning_zone ADD CONSTRAINT fkey_vl_planning_zone_kind FOREIGN KEY (kind) REFERENCES qgep_vl.planning_zone_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.infiltration_zone ADD CONSTRAINT oorel_od_infiltration_zone_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.infiltration_zone ADD CONSTRAINT oorel_od_infiltration_zone_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.infiltration_zone_infiltration_capacity () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.infiltration_zone_infiltration_capacity ADD CONSTRAINT pkey_qgep_vl_infiltration_zone_infiltration_capacity_code PRIMARY KEY (code); INSERT INTO qgep_vl.infiltration_zone_infiltration_capacity (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (371,371,'good','gut','bonnes', 'zzz_gut', '', '', '', '', '', '', 'true'); @@ -4072,7 +4073,7 @@ ALTER TABLE qgep_vl.infiltration_zone_infiltration_capacity ADD CONSTRAINT pkey_ ALTER TABLE qgep_od.infiltration_zone ADD CONSTRAINT fkey_vl_infiltration_zone_infiltration_capacity FOREIGN KEY (infiltration_capacity) REFERENCES qgep_vl.infiltration_zone_infiltration_capacity (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.drainage_system ADD CONSTRAINT oorel_od_drainage_system_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.drainage_system ADD CONSTRAINT oorel_od_drainage_system_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.drainage_system_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.drainage_system_kind ADD CONSTRAINT pkey_qgep_vl_drainage_system_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.drainage_system_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4783,4783,'amelioration','Melioration','melioration', 'zzz_Melioration', '', '', '', '', '', '', 'true'); @@ -4084,7 +4085,7 @@ ALTER TABLE qgep_vl.drainage_system_kind ADD CONSTRAINT pkey_qgep_vl_drainage_sy ALTER TABLE qgep_od.drainage_system ADD CONSTRAINT fkey_vl_drainage_system_kind FOREIGN KEY (kind) REFERENCES qgep_vl.drainage_system_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.water_body_protection_sector ADD CONSTRAINT oorel_od_water_body_protection_sector_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.water_body_protection_sector ADD CONSTRAINT oorel_od_water_body_protection_sector_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.water_body_protection_sector_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.water_body_protection_sector_kind ADD CONSTRAINT pkey_qgep_vl_water_body_protection_sector_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.water_body_protection_sector_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (430,430,'A','A','A', 'A', 'A', '', '', '', '', '', 'true'); @@ -4098,8 +4099,8 @@ ALTER TABLE qgep_vl.water_body_protection_sector_kind ADD CONSTRAINT pkey_qgep_v ALTER TABLE qgep_od.water_body_protection_sector ADD CONSTRAINT fkey_vl_water_body_protection_sector_kind FOREIGN KEY (kind) REFERENCES qgep_vl.water_body_protection_sector_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.ground_water_protection_perimeter ADD CONSTRAINT oorel_od_ground_water_protection_perimeter_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE qgep_od.groundwater_protection_zone ADD CONSTRAINT oorel_od_groundwater_protection_zone_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.ground_water_protection_perimeter ADD CONSTRAINT oorel_od_ground_water_protection_perimeter_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.groundwater_protection_zone ADD CONSTRAINT oorel_od_groundwater_protection_zone_zone FOREIGN KEY (obj_id) REFERENCES qgep_od.zone(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.groundwater_protection_zone_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.groundwater_protection_zone_kind ADD CONSTRAINT pkey_qgep_vl_groundwater_protection_zone_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.groundwater_protection_zone_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (440,440,'S1','S1','S1', 'S1', '', '', '', '', '', '', 'true'); @@ -4122,7 +4123,7 @@ ALTER TABLE qgep_vl.pipe_profile_profile_type ADD CONSTRAINT pkey_qgep_vl_pipe_p REFERENCES qgep_vl.pipe_profile_profile_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.wwtp_energy_use ADD COLUMN fk_waste_water_treatment_plant varchar (16); -ALTER TABLE qgep_od.wwtp_energy_use ADD CONSTRAINT rel_wwtp_energy_use_waste_water_treatment_plant FOREIGN KEY (fk_waste_water_treatment_plant) REFERENCES qgep_od.waste_water_treatment_plant(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.wwtp_energy_use ADD CONSTRAINT rel_wwtp_energy_use_waste_water_treatment_plant FOREIGN KEY (fk_waste_water_treatment_plant) REFERENCES qgep_od.waste_water_treatment_plant(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.waste_water_treatment_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.waste_water_treatment_kind ADD CONSTRAINT pkey_qgep_vl_waste_water_treatment_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.waste_water_treatment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3210,3210,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); @@ -4135,7 +4136,7 @@ ALTER TABLE qgep_vl.waste_water_treatment_kind ADD CONSTRAINT pkey_qgep_vl_waste REFERENCES qgep_vl.waste_water_treatment_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.waste_water_treatment ADD COLUMN fk_waste_water_treatment_plant varchar (16); -ALTER TABLE qgep_od.waste_water_treatment ADD CONSTRAINT rel_waste_water_treatment_waste_water_treatment_plant FOREIGN KEY (fk_waste_water_treatment_plant) REFERENCES qgep_od.waste_water_treatment_plant(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.waste_water_treatment ADD CONSTRAINT rel_waste_water_treatment_waste_water_treatment_plant FOREIGN KEY (fk_waste_water_treatment_plant) REFERENCES qgep_od.waste_water_treatment_plant(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.sludge_treatment_stabilisation () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.sludge_treatment_stabilisation ADD CONSTRAINT pkey_qgep_vl_sludge_treatment_stabilisation_code PRIMARY KEY (code); INSERT INTO qgep_vl.sludge_treatment_stabilisation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (141,141,'aerob_cold','aerobkalt','aerobie_froid', 'zzz_aerobkalt', '', '', '', '', '', '', 'true'); @@ -4149,11 +4150,11 @@ ALTER TABLE qgep_vl.sludge_treatment_stabilisation ADD CONSTRAINT pkey_qgep_vl_s REFERENCES qgep_vl.sludge_treatment_stabilisation (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.sludge_treatment ADD COLUMN fk_waste_water_treatment_plant varchar (16); -ALTER TABLE qgep_od.sludge_treatment ADD CONSTRAINT rel_sludge_treatment_waste_water_treatment_plant FOREIGN KEY (fk_waste_water_treatment_plant) REFERENCES qgep_od.waste_water_treatment_plant(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.sludge_treatment ADD CONSTRAINT rel_sludge_treatment_waste_water_treatment_plant FOREIGN KEY (fk_waste_water_treatment_plant) REFERENCES qgep_od.waste_water_treatment_plant(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.water_control_structure ADD COLUMN fk_water_course_segment varchar (16); -ALTER TABLE qgep_od.water_control_structure ADD CONSTRAINT rel_water_control_structure_water_course_segment FOREIGN KEY (fk_water_course_segment) REFERENCES qgep_od.water_course_segment(obj_id) ON UPDATE CASCADE ON DELETE set null; -ALTER TABLE qgep_od.ford ADD CONSTRAINT oorel_od_ford_water_control_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.water_control_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE qgep_od.chute ADD CONSTRAINT oorel_od_chute_water_control_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.water_control_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.water_control_structure ADD CONSTRAINT rel_water_control_structure_water_course_segment FOREIGN KEY (fk_water_course_segment) REFERENCES qgep_od.water_course_segment(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.ford ADD CONSTRAINT oorel_od_ford_water_control_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.water_control_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.chute ADD CONSTRAINT oorel_od_chute_water_control_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.water_control_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.chute_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.chute_kind ADD CONSTRAINT pkey_qgep_vl_chute_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.chute_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3591,3591,'artificial','kuenstlich','artificiel', 'zzz_kuenstlich', '', '', '', '', '', '', 'true'); @@ -4174,9 +4175,9 @@ ALTER TABLE qgep_vl.chute_material ADD CONSTRAINT pkey_qgep_vl_chute_material_co REFERENCES qgep_vl.chute_material (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.lock ADD CONSTRAINT oorel_od_lock_water_control_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.water_control_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE qgep_od.passage ADD CONSTRAINT oorel_od_passage_water_control_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.water_control_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE qgep_od.blocking_debris ADD CONSTRAINT oorel_od_blocking_debris_water_control_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.water_control_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE qgep_od.dam ADD CONSTRAINT oorel_od_dam_water_control_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.water_control_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.passage ADD CONSTRAINT oorel_od_passage_water_control_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.water_control_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.blocking_debris ADD CONSTRAINT oorel_od_blocking_debris_water_control_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.water_control_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.dam ADD CONSTRAINT oorel_od_dam_water_control_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.water_control_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.dam_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.dam_kind ADD CONSTRAINT pkey_qgep_vl_dam_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.dam_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (416,416,'retaining_weir','Stauwehr','digue_reservoir', 'zzz_Stauwehr', '', '', '', '', '', '', 'true'); @@ -4187,7 +4188,7 @@ ALTER TABLE qgep_vl.dam_kind ADD CONSTRAINT pkey_qgep_vl_dam_kind_code PRIMARY K ALTER TABLE qgep_od.dam ADD CONSTRAINT fkey_vl_dam_kind FOREIGN KEY (kind) REFERENCES qgep_vl.dam_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.rock_ramp ADD CONSTRAINT oorel_od_rock_ramp_water_control_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.water_control_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.rock_ramp ADD CONSTRAINT oorel_od_rock_ramp_water_control_structure FOREIGN KEY (obj_id) REFERENCES qgep_od.water_control_structure(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.rock_ramp_stabilisation () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.rock_ramp_stabilisation ADD CONSTRAINT pkey_qgep_vl_rock_ramp_stabilisation_code PRIMARY KEY (code); INSERT INTO qgep_vl.rock_ramp_stabilisation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2635,2635,'other_smooth','andere_glatt','autres_lisse', 'zzz_altri_glatt', '', '', '', '', '', '', 'true'); @@ -4201,11 +4202,11 @@ ALTER TABLE qgep_vl.rock_ramp_stabilisation ADD CONSTRAINT pkey_qgep_vl_rock_ram REFERENCES qgep_vl.rock_ramp_stabilisation (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.fish_pass ADD COLUMN fk_water_control_structure varchar (16); -ALTER TABLE qgep_od.fish_pass ADD CONSTRAINT rel_fish_pass_water_control_structure FOREIGN KEY (fk_water_control_structure) REFERENCES qgep_od.water_control_structure(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.fish_pass ADD CONSTRAINT rel_fish_pass_water_control_structure FOREIGN KEY (fk_water_control_structure) REFERENCES qgep_od.water_control_structure(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.bathing_area ADD COLUMN fk_surface_water_bodies varchar (16); -ALTER TABLE qgep_od.bathing_area ADD CONSTRAINT rel_bathing_area_surface_water_bodies FOREIGN KEY (fk_surface_water_bodies) REFERENCES qgep_od.surface_water_bodies(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.bathing_area ADD CONSTRAINT rel_bathing_area_surface_water_bodies FOREIGN KEY (fk_surface_water_bodies) REFERENCES qgep_od.surface_water_bodies(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.wastewater_networkelement ADD COLUMN fk_wastewater_structure varchar (16); -ALTER TABLE qgep_od.wastewater_networkelement ADD CONSTRAINT rel_wastewater_networkelement_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.wastewater_networkelement ADD CONSTRAINT rel_wastewater_networkelement_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.reach_point_elevation_accuracy () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.reach_point_elevation_accuracy ADD CONSTRAINT pkey_qgep_vl_reach_point_elevation_accuracy_code PRIMARY KEY (code); INSERT INTO qgep_vl.reach_point_elevation_accuracy (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3248,3248,'more_than_6cm','groesser_6cm','plusque_6cm', 'piu_6cm', 'mai_mare_6cm', '', 'G06', 'S06', '', '', 'true'); @@ -4227,11 +4228,11 @@ ALTER TABLE qgep_vl.reach_point_outlet_shape ADD CONSTRAINT pkey_qgep_vl_reach_p REFERENCES qgep_vl.reach_point_outlet_shape (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.reach_point ADD COLUMN fk_wastewater_networkelement varchar (16); -ALTER TABLE qgep_od.reach_point ADD CONSTRAINT rel_reach_point_wastewater_networkelement FOREIGN KEY (fk_wastewater_networkelement) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY IMMEDIATE; -ALTER TABLE qgep_od.wastewater_node ADD CONSTRAINT oorel_od_wastewater_node_wastewater_networkelement FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.reach_point ADD CONSTRAINT rel_reach_point_wastewater_networkelement FOREIGN KEY (fk_wastewater_networkelement) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.wastewater_node ADD CONSTRAINT oorel_od_wastewater_node_wastewater_networkelement FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.wastewater_node ADD COLUMN fk_hydr_geometry varchar (16); -ALTER TABLE qgep_od.wastewater_node ADD CONSTRAINT rel_wastewater_node_hydr_geometry FOREIGN KEY (fk_hydr_geometry) REFERENCES qgep_od.hydr_geometry(obj_id) ON UPDATE CASCADE ON DELETE cascade; -ALTER TABLE qgep_od.reach ADD CONSTRAINT oorel_od_reach_wastewater_networkelement FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.wastewater_node ADD CONSTRAINT rel_wastewater_node_hydr_geometry FOREIGN KEY (fk_hydr_geometry) REFERENCES qgep_od.hydr_geometry(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.reach ADD CONSTRAINT oorel_od_reach_wastewater_networkelement FOREIGN KEY (obj_id) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.reach_elevation_determination () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.reach_elevation_determination ADD CONSTRAINT pkey_qgep_vl_reach_elevation_determination_code PRIMARY KEY (code); INSERT INTO qgep_vl.reach_elevation_determination (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (4780,4780,'accurate','genau','precise', 'precisa', 'precisa', '', 'LG', 'P', '', '', 'true'); @@ -4332,15 +4333,15 @@ ALTER TABLE qgep_vl.reach_relining_kind ADD CONSTRAINT pkey_qgep_vl_reach_relini REFERENCES qgep_vl.reach_relining_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.reach ADD COLUMN fk_reach_point_from varchar (16); -ALTER TABLE qgep_od.reach ADD CONSTRAINT rel_reach_reach_point_from FOREIGN KEY (fk_reach_point_from) REFERENCES qgep_od.reach_point(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.reach ADD CONSTRAINT rel_reach_reach_point_from FOREIGN KEY (fk_reach_point_from) REFERENCES qgep_od.reach_point(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.reach ADD COLUMN fk_reach_point_to varchar (16); -ALTER TABLE qgep_od.reach ADD CONSTRAINT rel_reach_reach_point_to FOREIGN KEY (fk_reach_point_to) REFERENCES qgep_od.reach_point(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.reach ADD CONSTRAINT rel_reach_reach_point_to FOREIGN KEY (fk_reach_point_to) REFERENCES qgep_od.reach_point(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.reach ADD COLUMN fk_pipe_profile varchar (16); -ALTER TABLE qgep_od.reach ADD CONSTRAINT rel_reach_pipe_profile FOREIGN KEY (fk_pipe_profile) REFERENCES qgep_od.pipe_profile(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.reach ADD CONSTRAINT rel_reach_pipe_profile FOREIGN KEY (fk_pipe_profile) REFERENCES qgep_od.pipe_profile(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.profile_geometry ADD COLUMN fk_pipe_profile varchar (16); -ALTER TABLE qgep_od.profile_geometry ADD CONSTRAINT rel_profile_geometry_pipe_profile FOREIGN KEY (fk_pipe_profile) REFERENCES qgep_od.pipe_profile(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.profile_geometry ADD CONSTRAINT rel_profile_geometry_pipe_profile FOREIGN KEY (fk_pipe_profile) REFERENCES qgep_od.pipe_profile(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.hydr_geom_relation ADD COLUMN fk_hydr_geometry varchar (16); -ALTER TABLE qgep_od.hydr_geom_relation ADD CONSTRAINT rel_hydr_geom_relation_hydr_geometry FOREIGN KEY (fk_hydr_geometry) REFERENCES qgep_od.hydr_geometry(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.hydr_geom_relation ADD CONSTRAINT rel_hydr_geom_relation_hydr_geometry FOREIGN KEY (fk_hydr_geometry) REFERENCES qgep_od.hydr_geometry(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.mechanical_pretreatment_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.mechanical_pretreatment_kind ADD CONSTRAINT pkey_qgep_vl_mechanical_pretreatment_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.mechanical_pretreatment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3317,3317,'filter_bag','Filtersack','percolateur', 'zzz_Filtersack', '', '', '', '', '', '', 'true'); @@ -4353,9 +4354,9 @@ ALTER TABLE qgep_vl.mechanical_pretreatment_kind ADD CONSTRAINT pkey_qgep_vl_mec REFERENCES qgep_vl.mechanical_pretreatment_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.mechanical_pretreatment ADD COLUMN fk_infiltration_installation varchar (16); -ALTER TABLE qgep_od.mechanical_pretreatment ADD CONSTRAINT rel_mechanical_pretreatment_infiltration_installation FOREIGN KEY (fk_infiltration_installation) REFERENCES qgep_od.infiltration_installation(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.mechanical_pretreatment ADD CONSTRAINT rel_mechanical_pretreatment_infiltration_installation FOREIGN KEY (fk_infiltration_installation) REFERENCES qgep_od.infiltration_installation(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.mechanical_pretreatment ADD COLUMN fk_wastewater_structure varchar (16); -ALTER TABLE qgep_od.mechanical_pretreatment ADD CONSTRAINT rel_mechanical_pretreatment_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.mechanical_pretreatment ADD CONSTRAINT rel_mechanical_pretreatment_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.retention_body_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.retention_body_kind ADD CONSTRAINT pkey_qgep_vl_retention_body_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.retention_body_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2992,2992,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); @@ -4368,7 +4369,7 @@ ALTER TABLE qgep_vl.retention_body_kind ADD CONSTRAINT pkey_qgep_vl_retention_bo REFERENCES qgep_vl.retention_body_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.retention_body ADD COLUMN fk_infiltration_installation varchar (16); -ALTER TABLE qgep_od.retention_body ADD CONSTRAINT rel_retention_body_infiltration_installation FOREIGN KEY (fk_infiltration_installation) REFERENCES qgep_od.infiltration_installation(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.retention_body ADD CONSTRAINT rel_retention_body_infiltration_installation FOREIGN KEY (fk_infiltration_installation) REFERENCES qgep_od.infiltration_installation(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.overflow_char_kind_overflow_char () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.overflow_char_kind_overflow_char ADD CONSTRAINT pkey_qgep_vl_overflow_char_kind_overflow_char_code PRIMARY KEY (code); INSERT INTO qgep_vl.overflow_char_kind_overflow_char (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (6220,6220,'hq','HQ','HQ', 'HQ', '', '', '', '', '', '', 'true'); @@ -4386,7 +4387,7 @@ ALTER TABLE qgep_vl.overflow_char_overflow_char_digital ADD CONSTRAINT pkey_qgep REFERENCES qgep_vl.overflow_char_overflow_char_digital (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.hq_relation ADD COLUMN fk_overflow_char varchar (16); -ALTER TABLE qgep_od.hq_relation ADD CONSTRAINT rel_hq_relation_overflow_char FOREIGN KEY (fk_overflow_char) REFERENCES qgep_od.overflow_char(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.hq_relation ADD CONSTRAINT rel_hq_relation_overflow_char FOREIGN KEY (fk_overflow_char) REFERENCES qgep_od.overflow_char(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.structure_part_renovation_demand () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.structure_part_renovation_demand ADD CONSTRAINT pkey_qgep_vl_structure_part_renovation_demand_code PRIMARY KEY (code); INSERT INTO qgep_vl.structure_part_renovation_demand (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (138,138,'not_necessary','nicht_notwendig','pas_necessaire', 'zzz_nicht_notwendig', 'nenecesare', 'NN', 'NN', 'PN', '', '', 'true'); @@ -4396,9 +4397,9 @@ ALTER TABLE qgep_vl.structure_part_renovation_demand ADD CONSTRAINT pkey_qgep_vl REFERENCES qgep_vl.structure_part_renovation_demand (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.structure_part ADD COLUMN fk_wastewater_structure varchar (16); -ALTER TABLE qgep_od.structure_part ADD CONSTRAINT rel_structure_part_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY IMMEDIATE; -ALTER TABLE qgep_od.dryweather_downspout ADD CONSTRAINT oorel_od_dryweather_downspout_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE qgep_od.access_aid ADD CONSTRAINT oorel_od_access_aid_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.structure_part ADD CONSTRAINT rel_structure_part_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.dryweather_downspout ADD CONSTRAINT oorel_od_dryweather_downspout_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.access_aid ADD CONSTRAINT oorel_od_access_aid_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.access_aid_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.access_aid_kind ADD CONSTRAINT pkey_qgep_vl_access_aid_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.access_aid_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5357,5357,'other','andere','autre', 'altro', 'altul', 'O', 'A', 'AU', '', '', 'true'); @@ -4413,7 +4414,7 @@ ALTER TABLE qgep_vl.access_aid_kind ADD CONSTRAINT pkey_qgep_vl_access_aid_kind_ ALTER TABLE qgep_od.access_aid ADD CONSTRAINT fkey_vl_access_aid_kind FOREIGN KEY (kind) REFERENCES qgep_vl.access_aid_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.dryweather_flume ADD CONSTRAINT oorel_od_dryweather_flume_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.dryweather_flume ADD CONSTRAINT oorel_od_dryweather_flume_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.dryweather_flume_material () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.dryweather_flume_material ADD CONSTRAINT pkey_qgep_vl_dryweather_flume_material_code PRIMARY KEY (code); INSERT INTO qgep_vl.dryweather_flume_material (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3221,3221,'other','andere','autres', 'altri', 'alta', 'O', 'A', 'AU', '', '', 'true'); @@ -4425,7 +4426,7 @@ ALTER TABLE qgep_vl.dryweather_flume_material ADD CONSTRAINT pkey_qgep_vl_drywea ALTER TABLE qgep_od.dryweather_flume ADD CONSTRAINT fkey_vl_dryweather_flume_material FOREIGN KEY (material) REFERENCES qgep_vl.dryweather_flume_material (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.cover ADD CONSTRAINT oorel_od_cover_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.cover ADD CONSTRAINT oorel_od_cover_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.cover_cover_shape () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.cover_cover_shape ADD CONSTRAINT pkey_qgep_vl_cover_cover_shape_code PRIMARY KEY (code); INSERT INTO qgep_vl.cover_cover_shape (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5353,5353,'other','andere','autre', 'altro', 'altul', 'O', 'A', 'AU', '', '', 'true'); @@ -4480,7 +4481,7 @@ ALTER TABLE qgep_vl.cover_venting ADD CONSTRAINT pkey_qgep_vl_cover_venting_code ALTER TABLE qgep_od.cover ADD CONSTRAINT fkey_vl_cover_venting FOREIGN KEY (venting) REFERENCES qgep_vl.cover_venting (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.electric_equipment ADD CONSTRAINT oorel_od_electric_equipment_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.electric_equipment ADD CONSTRAINT oorel_od_electric_equipment_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.electric_equipment_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.electric_equipment_kind ADD CONSTRAINT pkey_qgep_vl_electric_equipment_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.electric_equipment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2980,2980,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); @@ -4492,7 +4493,7 @@ ALTER TABLE qgep_vl.electric_equipment_kind ADD CONSTRAINT pkey_qgep_vl_electric ALTER TABLE qgep_od.electric_equipment ADD CONSTRAINT fkey_vl_electric_equipment_kind FOREIGN KEY (kind) REFERENCES qgep_vl.electric_equipment_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.electromechanical_equipment ADD CONSTRAINT oorel_od_electromechanical_equipment_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.electromechanical_equipment ADD CONSTRAINT oorel_od_electromechanical_equipment_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.electromechanical_equipment_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.electromechanical_equipment_kind ADD CONSTRAINT pkey_qgep_vl_electromechanical_equipment_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.electromechanical_equipment_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2981,2981,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); @@ -4503,7 +4504,7 @@ ALTER TABLE qgep_vl.electromechanical_equipment_kind ADD CONSTRAINT pkey_qgep_vl ALTER TABLE qgep_od.electromechanical_equipment ADD CONSTRAINT fkey_vl_electromechanical_equipment_kind FOREIGN KEY (kind) REFERENCES qgep_vl.electromechanical_equipment_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.benching ADD CONSTRAINT oorel_od_benching_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.benching ADD CONSTRAINT oorel_od_benching_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.benching_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.benching_kind ADD CONSTRAINT pkey_qgep_vl_benching_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.benching_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5319,5319,'other','andere','autre', 'altro', 'alta', '', '', '', '', '', 'true'); @@ -4515,14 +4516,14 @@ ALTER TABLE qgep_vl.benching_kind ADD CONSTRAINT pkey_qgep_vl_benching_kind_code REFERENCES qgep_vl.benching_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.connection_object ADD COLUMN fk_wastewater_networkelement varchar (16); -ALTER TABLE qgep_od.connection_object ADD CONSTRAINT rel_connection_object_wastewater_networkelement FOREIGN KEY (fk_wastewater_networkelement) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.connection_object ADD CONSTRAINT rel_connection_object_wastewater_networkelement FOREIGN KEY (fk_wastewater_networkelement) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.connection_object ADD COLUMN fk_owner varchar (16); -ALTER TABLE qgep_od.connection_object ADD CONSTRAINT rel_connection_object_owner FOREIGN KEY (fk_owner) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.connection_object ADD CONSTRAINT rel_connection_object_owner FOREIGN KEY (fk_owner) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.connection_object ADD COLUMN fk_operator varchar (16); -ALTER TABLE qgep_od.connection_object ADD CONSTRAINT rel_connection_object_operator FOREIGN KEY (fk_operator) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null; -ALTER TABLE qgep_od.building ADD CONSTRAINT oorel_od_building_connection_object FOREIGN KEY (obj_id) REFERENCES qgep_od.connection_object(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE qgep_od.reservoir ADD CONSTRAINT oorel_od_reservoir_connection_object FOREIGN KEY (obj_id) REFERENCES qgep_od.connection_object(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE qgep_od.individual_surface ADD CONSTRAINT oorel_od_individual_surface_connection_object FOREIGN KEY (obj_id) REFERENCES qgep_od.connection_object(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.connection_object ADD CONSTRAINT rel_connection_object_operator FOREIGN KEY (fk_operator) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.building ADD CONSTRAINT oorel_od_building_connection_object FOREIGN KEY (obj_id) REFERENCES qgep_od.connection_object(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.reservoir ADD CONSTRAINT oorel_od_reservoir_connection_object FOREIGN KEY (obj_id) REFERENCES qgep_od.connection_object(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.individual_surface ADD CONSTRAINT oorel_od_individual_surface_connection_object FOREIGN KEY (obj_id) REFERENCES qgep_od.connection_object(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.individual_surface_function () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.individual_surface_function ADD CONSTRAINT pkey_qgep_vl_individual_surface_function_code PRIMARY KEY (code); INSERT INTO qgep_vl.individual_surface_function (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2979,2979,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); @@ -4549,15 +4550,15 @@ ALTER TABLE qgep_vl.individual_surface_pavement ADD CONSTRAINT pkey_qgep_vl_indi ALTER TABLE qgep_od.individual_surface ADD CONSTRAINT fkey_vl_individual_surface_pavement FOREIGN KEY (pavement) REFERENCES qgep_vl.individual_surface_pavement (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.fountain ADD CONSTRAINT oorel_od_fountain_connection_object FOREIGN KEY (obj_id) REFERENCES qgep_od.connection_object(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.fountain ADD CONSTRAINT oorel_od_fountain_connection_object FOREIGN KEY (obj_id) REFERENCES qgep_od.connection_object(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.hazard_source ADD COLUMN fk_connection_object varchar (16); -ALTER TABLE qgep_od.hazard_source ADD CONSTRAINT rel_hazard_source_connection_object FOREIGN KEY (fk_connection_object) REFERENCES qgep_od.connection_object(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.hazard_source ADD CONSTRAINT rel_hazard_source_connection_object FOREIGN KEY (fk_connection_object) REFERENCES qgep_od.connection_object(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.hazard_source ADD COLUMN fk_owner varchar (16); -ALTER TABLE qgep_od.hazard_source ADD CONSTRAINT rel_hazard_source_owner FOREIGN KEY (fk_owner) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.hazard_source ADD CONSTRAINT rel_hazard_source_owner FOREIGN KEY (fk_owner) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.accident ADD COLUMN fk_hazard_source varchar (16); -ALTER TABLE qgep_od.accident ADD CONSTRAINT rel_accident_hazard_source FOREIGN KEY (fk_hazard_source) REFERENCES qgep_od.hazard_source(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.accident ADD CONSTRAINT rel_accident_hazard_source FOREIGN KEY (fk_hazard_source) REFERENCES qgep_od.hazard_source(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.substance ADD COLUMN fk_hazard_source varchar (16); -ALTER TABLE qgep_od.substance ADD CONSTRAINT rel_substance_hazard_source FOREIGN KEY (fk_hazard_source) REFERENCES qgep_od.hazard_source(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.substance ADD CONSTRAINT rel_substance_hazard_source FOREIGN KEY (fk_hazard_source) REFERENCES qgep_od.hazard_source(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.catchment_area_direct_discharge_current () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.catchment_area_direct_discharge_current ADD CONSTRAINT pkey_qgep_vl_catchment_area_direct_discharge_current_code PRIMARY KEY (code); INSERT INTO qgep_vl.catchment_area_direct_discharge_current (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5457,5457,'yes','ja','oui', 'si', '', '', '', '', '', '', 'true'); @@ -4629,15 +4630,15 @@ ALTER TABLE qgep_vl.catchment_area_retention_planned ADD CONSTRAINT pkey_qgep_vl REFERENCES qgep_vl.catchment_area_retention_planned (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.catchment_area ADD COLUMN fk_wastewater_networkelement_rw_current varchar (16); -ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT rel_catchment_area_wastewater_networkelement_rw_current FOREIGN KEY (fk_wastewater_networkelement_rw_current) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT rel_catchment_area_wastewater_networkelement_rw_current FOREIGN KEY (fk_wastewater_networkelement_rw_current) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.catchment_area ADD COLUMN fk_wastewater_networkelement_rw_planned varchar (16); -ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT rel_catchment_area_wastewater_networkelement_rw_planned FOREIGN KEY (fk_wastewater_networkelement_rw_planned) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT rel_catchment_area_wastewater_networkelement_rw_planned FOREIGN KEY (fk_wastewater_networkelement_rw_planned) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.catchment_area ADD COLUMN fk_wastewater_networkelement_ww_planned varchar (16); -ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT rel_catchment_area_wastewater_networkelement_ww_planned FOREIGN KEY (fk_wastewater_networkelement_ww_planned) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT rel_catchment_area_wastewater_networkelement_ww_planned FOREIGN KEY (fk_wastewater_networkelement_ww_planned) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.catchment_area ADD COLUMN fk_wastewater_networkelement_ww_current varchar (16); -ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT rel_catchment_area_wastewater_networkelement_ww_current FOREIGN KEY (fk_wastewater_networkelement_ww_current) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.catchment_area ADD CONSTRAINT rel_catchment_area_wastewater_networkelement_ww_current FOREIGN KEY (fk_wastewater_networkelement_ww_current) REFERENCES qgep_od.wastewater_networkelement(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.surface_runoff_parameters ADD COLUMN fk_catchment_area varchar (16); -ALTER TABLE qgep_od.surface_runoff_parameters ADD CONSTRAINT rel_surface_runoff_parameters_catchment_area FOREIGN KEY (fk_catchment_area) REFERENCES qgep_od.catchment_area(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.surface_runoff_parameters ADD CONSTRAINT rel_surface_runoff_parameters_catchment_area FOREIGN KEY (fk_catchment_area) REFERENCES qgep_od.catchment_area(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.measuring_point_damming_device () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.measuring_point_damming_device ADD CONSTRAINT pkey_qgep_vl_measuring_point_damming_device_code PRIMARY KEY (code); INSERT INTO qgep_vl.measuring_point_damming_device (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5720,5720,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); @@ -4658,13 +4659,13 @@ ALTER TABLE qgep_vl.measuring_point_purpose ADD CONSTRAINT pkey_qgep_vl_measurin REFERENCES qgep_vl.measuring_point_purpose (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.measuring_point ADD COLUMN fk_operator varchar (16); -ALTER TABLE qgep_od.measuring_point ADD CONSTRAINT rel_measuring_point_operator FOREIGN KEY (fk_operator) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.measuring_point ADD CONSTRAINT rel_measuring_point_operator FOREIGN KEY (fk_operator) REFERENCES qgep_od.organisation(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.measuring_point ADD COLUMN fk_waste_water_treatment_plant varchar (16); -ALTER TABLE qgep_od.measuring_point ADD CONSTRAINT rel_measuring_point_waste_water_treatment_plant FOREIGN KEY (fk_waste_water_treatment_plant) REFERENCES qgep_od.waste_water_treatment_plant(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.measuring_point ADD CONSTRAINT rel_measuring_point_waste_water_treatment_plant FOREIGN KEY (fk_waste_water_treatment_plant) REFERENCES qgep_od.waste_water_treatment_plant(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.measuring_point ADD COLUMN fk_wastewater_structure varchar (16); -ALTER TABLE qgep_od.measuring_point ADD CONSTRAINT rel_measuring_point_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.measuring_point ADD CONSTRAINT rel_measuring_point_wastewater_structure FOREIGN KEY (fk_wastewater_structure) REFERENCES qgep_od.wastewater_structure(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.measuring_point ADD COLUMN fk_water_course_segment varchar (16); -ALTER TABLE qgep_od.measuring_point ADD CONSTRAINT rel_measuring_point_water_course_segment FOREIGN KEY (fk_water_course_segment) REFERENCES qgep_od.water_course_segment(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.measuring_point ADD CONSTRAINT rel_measuring_point_water_course_segment FOREIGN KEY (fk_water_course_segment) REFERENCES qgep_od.water_course_segment(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.measuring_device_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.measuring_device_kind ADD CONSTRAINT pkey_qgep_vl_measuring_device_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.measuring_device_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5702,5702,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); @@ -4680,7 +4681,7 @@ ALTER TABLE qgep_vl.measuring_device_kind ADD CONSTRAINT pkey_qgep_vl_measuring_ REFERENCES qgep_vl.measuring_device_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.measuring_device ADD COLUMN fk_measuring_point varchar (16); -ALTER TABLE qgep_od.measuring_device ADD CONSTRAINT rel_measuring_device_measuring_point FOREIGN KEY (fk_measuring_point) REFERENCES qgep_od.measuring_point(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.measuring_device ADD CONSTRAINT rel_measuring_device_measuring_point FOREIGN KEY (fk_measuring_point) REFERENCES qgep_od.measuring_point(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.measurement_series_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.measurement_series_kind ADD CONSTRAINT pkey_qgep_vl_measurement_series_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.measurement_series_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3217,3217,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); @@ -4691,7 +4692,7 @@ ALTER TABLE qgep_vl.measurement_series_kind ADD CONSTRAINT pkey_qgep_vl_measurem REFERENCES qgep_vl.measurement_series_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.measurement_series ADD COLUMN fk_measuring_point varchar (16); -ALTER TABLE qgep_od.measurement_series ADD CONSTRAINT rel_measurement_series_measuring_point FOREIGN KEY (fk_measuring_point) REFERENCES qgep_od.measuring_point(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.measurement_series ADD CONSTRAINT rel_measurement_series_measuring_point FOREIGN KEY (fk_measuring_point) REFERENCES qgep_od.measuring_point(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.measurement_result_measurement_type () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.measurement_result_measurement_type ADD CONSTRAINT pkey_qgep_vl_measurement_result_measurement_type_code PRIMARY KEY (code); INSERT INTO qgep_vl.measurement_result_measurement_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5732,5732,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); @@ -4702,9 +4703,9 @@ ALTER TABLE qgep_vl.measurement_result_measurement_type ADD CONSTRAINT pkey_qgep REFERENCES qgep_vl.measurement_result_measurement_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.measurement_result ADD COLUMN fk_measuring_device varchar (16); -ALTER TABLE qgep_od.measurement_result ADD CONSTRAINT rel_measurement_result_measuring_device FOREIGN KEY (fk_measuring_device) REFERENCES qgep_od.measuring_device(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.measurement_result ADD CONSTRAINT rel_measurement_result_measuring_device FOREIGN KEY (fk_measuring_device) REFERENCES qgep_od.measuring_device(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.measurement_result ADD COLUMN fk_measurement_series varchar (16); -ALTER TABLE qgep_od.measurement_result ADD CONSTRAINT rel_measurement_result_measurement_series FOREIGN KEY (fk_measurement_series) REFERENCES qgep_od.measurement_series(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.measurement_result ADD CONSTRAINT rel_measurement_result_measurement_series FOREIGN KEY (fk_measurement_series) REFERENCES qgep_od.measurement_series(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.overflow_actuation () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.overflow_actuation ADD CONSTRAINT pkey_qgep_vl_overflow_actuation_code PRIMARY KEY (code); INSERT INTO qgep_vl.overflow_actuation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3667,3667,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); @@ -4757,13 +4758,13 @@ ALTER TABLE qgep_vl.overflow_signal_transmission ADD CONSTRAINT pkey_qgep_vl_ove REFERENCES qgep_vl.overflow_signal_transmission (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.overflow ADD COLUMN fk_wastewater_node varchar (16); -ALTER TABLE qgep_od.overflow ADD CONSTRAINT rel_overflow_wastewater_node FOREIGN KEY (fk_wastewater_node) REFERENCES qgep_od.wastewater_node(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.overflow ADD CONSTRAINT rel_overflow_wastewater_node FOREIGN KEY (fk_wastewater_node) REFERENCES qgep_od.wastewater_node(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.overflow ADD COLUMN fk_overflow_to varchar (16); -ALTER TABLE qgep_od.overflow ADD CONSTRAINT rel_overflow_overflow_to FOREIGN KEY (fk_overflow_to) REFERENCES qgep_od.wastewater_node(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.overflow ADD CONSTRAINT rel_overflow_overflow_to FOREIGN KEY (fk_overflow_to) REFERENCES qgep_od.wastewater_node(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.overflow ADD COLUMN fk_overflow_char varchar (16); -ALTER TABLE qgep_od.overflow ADD CONSTRAINT rel_overflow_overflow_char FOREIGN KEY (fk_overflow_char) REFERENCES qgep_od.overflow_char(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.overflow ADD CONSTRAINT rel_overflow_overflow_char FOREIGN KEY (fk_overflow_char) REFERENCES qgep_od.overflow_char(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.overflow ADD COLUMN fk_control_center varchar (16); -ALTER TABLE qgep_od.overflow ADD CONSTRAINT rel_overflow_control_center FOREIGN KEY (fk_control_center) REFERENCES qgep_od.control_center(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.overflow ADD CONSTRAINT rel_overflow_control_center FOREIGN KEY (fk_control_center) REFERENCES qgep_od.control_center(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.throttle_shut_off_unit_actuation () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.throttle_shut_off_unit_actuation ADD CONSTRAINT pkey_qgep_vl_throttle_shut_off_unit_actuation_code PRIMARY KEY (code); INSERT INTO qgep_vl.throttle_shut_off_unit_actuation (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3213,3213,'other','andere','autres', 'altri', 'altul', '', '', '', '', '', 'true'); @@ -4825,12 +4826,12 @@ ALTER TABLE qgep_vl.throttle_shut_off_unit_signal_transmission ADD CONSTRAINT pk REFERENCES qgep_vl.throttle_shut_off_unit_signal_transmission (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.throttle_shut_off_unit ADD COLUMN fk_wastewater_node varchar (16); -ALTER TABLE qgep_od.throttle_shut_off_unit ADD CONSTRAINT rel_throttle_shut_off_unit_wastewater_node FOREIGN KEY (fk_wastewater_node) REFERENCES qgep_od.wastewater_node(obj_id) ON UPDATE CASCADE ON DELETE cascade; +ALTER TABLE qgep_od.throttle_shut_off_unit ADD CONSTRAINT rel_throttle_shut_off_unit_wastewater_node FOREIGN KEY (fk_wastewater_node) REFERENCES qgep_od.wastewater_node(obj_id) ON UPDATE CASCADE ON DELETE cascade DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.throttle_shut_off_unit ADD COLUMN fk_control_center varchar (16); -ALTER TABLE qgep_od.throttle_shut_off_unit ADD CONSTRAINT rel_throttle_shut_off_unit_control_center FOREIGN KEY (fk_control_center) REFERENCES qgep_od.control_center(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.throttle_shut_off_unit ADD CONSTRAINT rel_throttle_shut_off_unit_control_center FOREIGN KEY (fk_control_center) REFERENCES qgep_od.control_center(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.throttle_shut_off_unit ADD COLUMN fk_overflow varchar (16); -ALTER TABLE qgep_od.throttle_shut_off_unit ADD CONSTRAINT rel_throttle_shut_off_unit_overflow FOREIGN KEY (fk_overflow) REFERENCES qgep_od.overflow(obj_id) ON UPDATE CASCADE ON DELETE set null; -ALTER TABLE qgep_od.prank_weir ADD CONSTRAINT oorel_od_prank_weir_overflow FOREIGN KEY (obj_id) REFERENCES qgep_od.overflow(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.throttle_shut_off_unit ADD CONSTRAINT rel_throttle_shut_off_unit_overflow FOREIGN KEY (fk_overflow) REFERENCES qgep_od.overflow(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.prank_weir ADD CONSTRAINT oorel_od_prank_weir_overflow FOREIGN KEY (obj_id) REFERENCES qgep_od.overflow(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.prank_weir_weir_edge () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.prank_weir_weir_edge ADD CONSTRAINT pkey_qgep_vl_prank_weir_weir_edge_code PRIMARY KEY (code); INSERT INTO qgep_vl.prank_weir_weir_edge (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2995,2995,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); @@ -4848,7 +4849,7 @@ ALTER TABLE qgep_vl.prank_weir_weir_kind ADD CONSTRAINT pkey_qgep_vl_prank_weir_ ALTER TABLE qgep_od.prank_weir ADD CONSTRAINT fkey_vl_prank_weir_weir_kind FOREIGN KEY (weir_kind) REFERENCES qgep_vl.prank_weir_weir_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.pump ADD CONSTRAINT oorel_od_pump_overflow FOREIGN KEY (obj_id) REFERENCES qgep_od.overflow(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.pump ADD CONSTRAINT oorel_od_pump_overflow FOREIGN KEY (obj_id) REFERENCES qgep_od.overflow(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.pump_construction_type () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.pump_construction_type ADD CONSTRAINT pkey_qgep_vl_pump_contruction_type_code PRIMARY KEY (code); INSERT INTO qgep_vl.pump_construction_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (2983,2983,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); @@ -4891,7 +4892,7 @@ ALTER TABLE qgep_vl.pump_usage_current ADD CONSTRAINT pkey_qgep_vl_pump_usage_cu ALTER TABLE qgep_od.pump ADD CONSTRAINT fkey_vl_pump_usage_current FOREIGN KEY (usage_current) REFERENCES qgep_vl.pump_usage_current (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.leapingweir ADD CONSTRAINT oorel_od_leapingweir_overflow FOREIGN KEY (obj_id) REFERENCES qgep_od.overflow(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.leapingweir ADD CONSTRAINT oorel_od_leapingweir_overflow FOREIGN KEY (obj_id) REFERENCES qgep_od.overflow(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.leapingweir_opening_shape () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.leapingweir_opening_shape ADD CONSTRAINT pkey_qgep_vl_leapingweir_opening_shape_code PRIMARY KEY (code); INSERT INTO qgep_vl.leapingweir_opening_shape (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (3581,3581,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); @@ -4951,10 +4952,10 @@ ALTER TABLE qgep_vl.hydraulic_char_data_status ADD CONSTRAINT pkey_qgep_vl_hydra REFERENCES qgep_vl.hydraulic_char_data_status (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.hydraulic_char_data ADD COLUMN fk_wastewater_node varchar (16); -ALTER TABLE qgep_od.hydraulic_char_data ADD CONSTRAINT rel_hydraulic_char_data_wastewater_node FOREIGN KEY (fk_wastewater_node) REFERENCES qgep_od.wastewater_node(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.hydraulic_char_data ADD CONSTRAINT rel_hydraulic_char_data_wastewater_node FOREIGN KEY (fk_wastewater_node) REFERENCES qgep_od.wastewater_node(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.hydraulic_char_data ADD COLUMN fk_overflow_char varchar (16); -ALTER TABLE qgep_od.hydraulic_char_data ADD CONSTRAINT rel_hydraulic_char_data_overflow_char FOREIGN KEY (fk_overflow_char) REFERENCES qgep_od.overflow_char(obj_id) ON UPDATE CASCADE ON DELETE set null; -ALTER TABLE qgep_od.backflow_prevention ADD CONSTRAINT oorel_od_backflow_prevention_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.hydraulic_char_data ADD CONSTRAINT rel_hydraulic_char_data_overflow_char FOREIGN KEY (fk_overflow_char) REFERENCES qgep_od.overflow_char(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.backflow_prevention ADD CONSTRAINT oorel_od_backflow_prevention_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.backflow_prevention_kind () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.backflow_prevention_kind ADD CONSTRAINT pkey_qgep_vl_backflow_prevention_kind_code PRIMARY KEY (code); INSERT INTO qgep_vl.backflow_prevention_kind (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5760,5760,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); @@ -4965,10 +4966,10 @@ ALTER TABLE qgep_vl.backflow_prevention_kind ADD CONSTRAINT pkey_qgep_vl_backflo REFERENCES qgep_vl.backflow_prevention_kind (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.backflow_prevention ADD COLUMN fk_throttle_shut_off_unit varchar (16); -ALTER TABLE qgep_od.backflow_prevention ADD CONSTRAINT rel_backflow_prevention_throttle_shut_off_unit FOREIGN KEY (fk_throttle_shut_off_unit) REFERENCES qgep_od.throttle_shut_off_unit(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.backflow_prevention ADD CONSTRAINT rel_backflow_prevention_throttle_shut_off_unit FOREIGN KEY (fk_throttle_shut_off_unit) REFERENCES qgep_od.throttle_shut_off_unit(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.backflow_prevention ADD COLUMN fk_pump varchar (16); -ALTER TABLE qgep_od.backflow_prevention ADD CONSTRAINT rel_backflow_prevention_pump FOREIGN KEY (fk_pump) REFERENCES qgep_od.pump(obj_id) ON UPDATE CASCADE ON DELETE set null; -ALTER TABLE qgep_od.solids_retention ADD CONSTRAINT oorel_od_solids_retention_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.backflow_prevention ADD CONSTRAINT rel_backflow_prevention_pump FOREIGN KEY (fk_pump) REFERENCES qgep_od.pump(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.solids_retention ADD CONSTRAINT oorel_od_solids_retention_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.solids_retention_type () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.solids_retention_type ADD CONSTRAINT pkey_qgep_vl_solids_retention_type_code PRIMARY KEY (code); INSERT INTO qgep_vl.solids_retention_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5664,5664,'other','andere','autres', 'altri', '', '', '', '', '', '', 'true'); @@ -4980,7 +4981,7 @@ ALTER TABLE qgep_vl.solids_retention_type ADD CONSTRAINT pkey_qgep_vl_solids_ret ALTER TABLE qgep_od.solids_retention ADD CONSTRAINT fkey_vl_solids_retention_type FOREIGN KEY (type) REFERENCES qgep_vl.solids_retention_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.tank_cleaning ADD CONSTRAINT oorel_od_tank_cleaning_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.tank_cleaning ADD CONSTRAINT oorel_od_tank_cleaning_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.tank_cleaning_type () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.tank_cleaning_type ADD CONSTRAINT pkey_qgep_vl_tank_cleaning_type_code PRIMARY KEY (code); INSERT INTO qgep_vl.tank_cleaning_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5621,5621,'airjet','Air_Jet','aeration_et_brassage', 'airjet', '', '', '', '', '', '', 'true'); @@ -4991,7 +4992,7 @@ ALTER TABLE qgep_vl.tank_cleaning_type ADD CONSTRAINT pkey_qgep_vl_tank_cleaning ALTER TABLE qgep_od.tank_cleaning ADD CONSTRAINT fkey_vl_tank_cleaning_type FOREIGN KEY (type) REFERENCES qgep_vl.tank_cleaning_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; -ALTER TABLE qgep_od.tank_emptying ADD CONSTRAINT oorel_od_tank_emptying_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.tank_emptying ADD CONSTRAINT oorel_od_tank_emptying_structure_part FOREIGN KEY (obj_id) REFERENCES qgep_od.structure_part(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; CREATE TABLE qgep_vl.tank_emptying_type () INHERITS (qgep_sys.value_list_base); ALTER TABLE qgep_vl.tank_emptying_type ADD CONSTRAINT pkey_qgep_vl_tank_emptying_type_code PRIMARY KEY (code); INSERT INTO qgep_vl.tank_emptying_type (code, vsacode, value_en, value_de, value_fr, value_it, value_ro, abbr_en, abbr_de, abbr_fr, abbr_it, abbr_ro, active) VALUES (5626,5626,'other','andere','autre', 'altro', '', '', '', '', '', '', 'true'); @@ -5002,11 +5003,11 @@ ALTER TABLE qgep_vl.tank_emptying_type ADD CONSTRAINT pkey_qgep_vl_tank_emptying REFERENCES qgep_vl.tank_emptying_type (code) MATCH SIMPLE ON UPDATE RESTRICT ON DELETE RESTRICT; ALTER TABLE qgep_od.tank_emptying ADD COLUMN fk_throttle_shut_off_unit varchar (16); -ALTER TABLE qgep_od.tank_emptying ADD CONSTRAINT rel_tank_emptying_throttle_shut_off_unit FOREIGN KEY (fk_throttle_shut_off_unit) REFERENCES qgep_od.throttle_shut_off_unit(obj_id) ON UPDATE CASCADE ON DELETE set null; +ALTER TABLE qgep_od.tank_emptying ADD CONSTRAINT rel_tank_emptying_throttle_shut_off_unit FOREIGN KEY (fk_throttle_shut_off_unit) REFERENCES qgep_od.throttle_shut_off_unit(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.tank_emptying ADD COLUMN fk_overflow varchar (16); -ALTER TABLE qgep_od.tank_emptying ADD CONSTRAINT rel_tank_emptying_overflow FOREIGN KEY (fk_overflow) REFERENCES qgep_od.pump(obj_id) ON UPDATE CASCADE ON DELETE set null; -ALTER TABLE qgep_od.param_ca_general ADD CONSTRAINT oorel_od_param_ca_general_surface_runoff_parameters FOREIGN KEY (obj_id) REFERENCES qgep_od.surface_runoff_parameters(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; -ALTER TABLE qgep_od.param_ca_mouse1 ADD CONSTRAINT oorel_od_param_ca_mouse1_surface_runoff_parameters FOREIGN KEY (obj_id) REFERENCES qgep_od.surface_runoff_parameters(obj_id) ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE qgep_od.tank_emptying ADD CONSTRAINT rel_tank_emptying_overflow FOREIGN KEY (fk_overflow) REFERENCES qgep_od.pump(obj_id) ON UPDATE CASCADE ON DELETE set null DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.param_ca_general ADD CONSTRAINT oorel_od_param_ca_general_surface_runoff_parameters FOREIGN KEY (obj_id) REFERENCES qgep_od.surface_runoff_parameters(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.param_ca_mouse1 ADD CONSTRAINT oorel_od_param_ca_mouse1_surface_runoff_parameters FOREIGN KEY (obj_id) REFERENCES qgep_od.surface_runoff_parameters(obj_id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE INITIALLY DEFERRED; ------------ Text and Symbol Tables ----------- ; ------- @@ -5286,8 +5287,8 @@ ALTER TABLE qgep_od.river_bed ADD CONSTRAINT rel_od_river_bed_fk_dataowner FOREI ALTER TABLE qgep_od.river_bed ADD CONSTRAINT rel_od_river_bed_fk_dataprovider FOREIGN KEY (fk_provider) REFERENCES qgep_od.organisation(obj_id); ALTER TABLE qgep_od.sector_water_body ADD CONSTRAINT rel_od_sector_water_body_fk_dataowner FOREIGN KEY (fk_dataowner) REFERENCES qgep_od.organisation(obj_id); ALTER TABLE qgep_od.sector_water_body ADD CONSTRAINT rel_od_sector_water_body_fk_dataprovider FOREIGN KEY (fk_provider) REFERENCES qgep_od.organisation(obj_id); -ALTER TABLE qgep_od.organisation ADD CONSTRAINT rel_od_organisation_fk_dataowner FOREIGN KEY (fk_dataowner) REFERENCES qgep_od.organisation(obj_id); -ALTER TABLE qgep_od.organisation ADD CONSTRAINT rel_od_organisation_fk_dataprovider FOREIGN KEY (fk_provider) REFERENCES qgep_od.organisation(obj_id); +ALTER TABLE qgep_od.organisation ADD CONSTRAINT rel_od_organisation_fk_dataowner FOREIGN KEY (fk_dataowner) REFERENCES qgep_od.organisation(obj_id) DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.organisation ADD CONSTRAINT rel_od_organisation_fk_dataprovider FOREIGN KEY (fk_provider) REFERENCES qgep_od.organisation(obj_id) DEFERRABLE INITIALLY DEFERRED; ALTER TABLE qgep_od.wastewater_structure ADD CONSTRAINT rel_od_wastewater_structure_fk_dataowner FOREIGN KEY (fk_dataowner) REFERENCES qgep_od.organisation(obj_id); ALTER TABLE qgep_od.wastewater_structure ADD CONSTRAINT rel_od_wastewater_structure_fk_dataprovider FOREIGN KEY (fk_provider) REFERENCES qgep_od.organisation(obj_id); ALTER TABLE qgep_od.maintenance_event ADD CONSTRAINT rel_od_maintenance_event_fk_dataowner FOREIGN KEY (fk_dataowner) REFERENCES qgep_od.organisation(obj_id); diff --git a/06_symbology_functions.sql b/06_symbology_functions.sql index 11a91d2f..32fc2f14 100644 --- a/06_symbology_functions.sql +++ b/06_symbology_functions.sql @@ -328,6 +328,69 @@ BEGIN END; $BODY$ LANGUAGE plpgsql VOLATILE; +-------------------------------------------------------- +-- UPDATE wastewater structure fk_main_cover +-- Argument: +-- * obj_id of wastewater structure +-- * all True to update all +-- * omit both arguments to update all where fk_main_cover is null +-------------------------------------------------------- +CREATE OR REPLACE FUNCTION qgep_od.wastewater_structure_update_fk_main_cover(_obj_id text default NULL, _all boolean default false) + RETURNS VOID AS + $BODY$ + DECLARE + myrec record; + +BEGIN + UPDATE qgep_od.wastewater_structure ws + SET fk_main_cover = ws_covers.co_obj_id + FROM ( + SELECT ws.obj_id, min(co.obj_id) OVER (PARTITION BY ws.obj_id) AS co_obj_id + FROM qgep_od.wastewater_structure ws + LEFT JOIN qgep_od.structure_part sp ON sp.fk_wastewater_structure = ws.obj_id + LEFT JOIN qgep_od.cover co ON sp.obj_id = co.obj_id + LEFT JOIN qgep_od.channel ch ON ch.obj_id = ws.obj_id + WHERE ch.obj_id IS NULL AND (_all OR ws.obj_id = _obj_id OR ( NOT _all AND _obj_id is NULL AND ws.fk_main_cover IS NULL)) + ) ws_covers + WHERE ws.obj_id = ws_covers.obj_id; +END + +$BODY$ +LANGUAGE plpgsql +VOLATILE; + +-------------------------------------------------------- +-- UPDATE wastewater structure fk_main_wastewater_node +-- Argument: +-- * obj_id of wastewater structure +-- * all True to update all +-- * omit both arguments to update all where fk_main_wastewater_node is null +-------------------------------------------------------- + +CREATE OR REPLACE FUNCTION qgep_od.wastewater_structure_update_fk_main_wastewater_node(_obj_id text default NULL, _all boolean default false) + RETURNS VOID AS + $BODY$ + DECLARE + myrec record; + +BEGIN + UPDATE qgep_od.wastewater_structure ws + SET fk_main_wastewater_node = ws_nodes.wn_obj_id + FROM ( + SELECT ws.obj_id, min(wn.obj_id) OVER (PARTITION BY ws.obj_id) AS wn_obj_id + FROM qgep_od.wastewater_structure ws + LEFT JOIN qgep_od.wastewater_networkelement ne ON ne.fk_wastewater_structure = ws.obj_id + LEFT JOIN qgep_od.wastewater_node wn ON ne.obj_id = wn.obj_id + LEFT JOIN qgep_od.channel ch ON ch.obj_id = ws.obj_id + WHERE ch.obj_id IS NULL AND (_all OR ws.obj_id = _obj_id OR ( NOT _all AND _obj_id is NULL AND ws.fk_main_wastewater_node IS NULL)) + ) ws_nodes + WHERE ws.obj_id = ws_nodes.obj_id; +END + +$BODY$ +LANGUAGE plpgsql +VOLATILE; + -------------------------------------------------------- -- UPDATE wastewater structure depth -- Argument: diff --git a/delta/delta_1.6.0_noop.sql b/delta/delta_1.6.0_noop.sql deleted file mode 100644 index 9398b945..00000000 --- a/delta/delta_1.6.0_noop.sql +++ /dev/null @@ -1,2 +0,0 @@ --- noop delta, used only to unambigously define the datamodel version -SELECT 1; \ No newline at end of file diff --git a/delta/delta_1.6.2_add_dereferable_constraints.sql b/delta/delta_1.6.2_add_dereferable_constraints.sql new file mode 100644 index 00000000..b8c7716f --- /dev/null +++ b/delta/delta_1.6.2_add_dereferable_constraints.sql @@ -0,0 +1,240 @@ +--- Add additional DEREFERABLE constraints + +ALTER TABLE qgep_od.re_maintenance_event_wastewater_structure ALTER CONSTRAINT rel_maintenance_event_wastewater_structure_wastewater_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.re_maintenance_event_wastewater_structure ALTER CONSTRAINT rel_maintenance_event_wastewater_structure_maintenance_event DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.txt_symbol ALTER CONSTRAINT rel_symbol_wastewater_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.txt_text ALTER CONSTRAINT rel_text_wastewater_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.txt_text ALTER CONSTRAINT rel_text_catchment_area DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.txt_text ALTER CONSTRAINT rel_text_reach DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.river ALTER CONSTRAINT oorel_od_river_surface_water_bodies DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.lake ALTER CONSTRAINT oorel_od_lake_surface_water_bodies DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.water_course_segment ALTER CONSTRAINT rel_water_course_segment_watercourse DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.water_catchment ALTER CONSTRAINT rel_water_catchment_aquifier DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.water_catchment ALTER CONSTRAINT rel_water_catchment_surface_water_bodies DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.river_bank ALTER CONSTRAINT rel_river_bank_water_course_segment DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.river_bed ALTER CONSTRAINT rel_river_bed_water_course_segment DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.sector_water_body ALTER CONSTRAINT rel_sector_water_body_surface_water_bodies DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.cooperative ALTER CONSTRAINT oorel_od_cooperative_organisation DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.canton ALTER CONSTRAINT oorel_od_canton_organisation DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.waste_water_association ALTER CONSTRAINT oorel_od_waste_water_association_organisation DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.municipality ALTER CONSTRAINT oorel_od_municipality_organisation DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.administrative_office ALTER CONSTRAINT oorel_od_administrative_office_organisation DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.waste_water_treatment_plant ALTER CONSTRAINT oorel_od_waste_water_treatment_plant_organisation DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.private ALTER CONSTRAINT oorel_od_private_organisation DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.wastewater_structure ALTER CONSTRAINT rel_wastewater_structure_owner DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.wastewater_structure ALTER CONSTRAINT rel_wastewater_structure_operator DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.channel ALTER CONSTRAINT oorel_od_channel_wastewater_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.manhole ALTER CONSTRAINT oorel_od_manhole_wastewater_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.discharge_point ALTER CONSTRAINT oorel_od_discharge_point_wastewater_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.discharge_point ALTER CONSTRAINT rel_discharge_point_sector_water_body DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.special_structure ALTER CONSTRAINT oorel_od_special_structure_wastewater_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.infiltration_installation ALTER CONSTRAINT oorel_od_infiltration_installation_wastewater_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.infiltration_installation ALTER CONSTRAINT rel_infiltration_installation_aquifier DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.wwtp_structure ALTER CONSTRAINT oorel_od_wwtp_structure_wastewater_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.maintenance_event ALTER CONSTRAINT rel_maintenance_event_operating_company DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.planning_zone ALTER CONSTRAINT oorel_od_planning_zone_zone DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.infiltration_zone ALTER CONSTRAINT oorel_od_infiltration_zone_zone DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.drainage_system ALTER CONSTRAINT oorel_od_drainage_system_zone DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.water_body_protection_sector ALTER CONSTRAINT oorel_od_water_body_protection_sector_zone DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.ground_water_protection_perimeter ALTER CONSTRAINT oorel_od_ground_water_protection_perimeter_zone DEFERRABLE INITIALLY DEFERRED; +ALTER TABLE qgep_od.groundwater_protection_zone ALTER CONSTRAINT oorel_od_groundwater_protection_zone_zone DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.wwtp_energy_use ALTER CONSTRAINT rel_wwtp_energy_use_waste_water_treatment_plant DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.waste_water_treatment ALTER CONSTRAINT rel_waste_water_treatment_waste_water_treatment_plant DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.sludge_treatment ALTER CONSTRAINT rel_sludge_treatment_waste_water_treatment_plant DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.water_control_structure ALTER CONSTRAINT rel_water_control_structure_water_course_segment DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.ford ALTER CONSTRAINT oorel_od_ford_water_control_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.chute ALTER CONSTRAINT oorel_od_chute_water_control_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.passage ALTER CONSTRAINT oorel_od_passage_water_control_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.blocking_debris ALTER CONSTRAINT oorel_od_blocking_debris_water_control_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.dam ALTER CONSTRAINT oorel_od_dam_water_control_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.rock_ramp ALTER CONSTRAINT oorel_od_rock_ramp_water_control_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.fish_pass ALTER CONSTRAINT rel_fish_pass_water_control_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.bathing_area ALTER CONSTRAINT rel_bathing_area_surface_water_bodies DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.wastewater_networkelement ALTER CONSTRAINT rel_wastewater_networkelement_wastewater_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.reach_point ALTER CONSTRAINT rel_reach_point_wastewater_networkelement DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.wastewater_node ALTER CONSTRAINT oorel_od_wastewater_node_wastewater_networkelement DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.wastewater_node ALTER CONSTRAINT rel_wastewater_node_hydr_geometry DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.reach ALTER CONSTRAINT oorel_od_reach_wastewater_networkelement DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.reach ALTER CONSTRAINT rel_reach_reach_point_from DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.reach ALTER CONSTRAINT rel_reach_reach_point_to DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.reach ALTER CONSTRAINT rel_reach_pipe_profile DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.profile_geometry ALTER CONSTRAINT rel_profile_geometry_pipe_profile DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.hydr_geom_relation ALTER CONSTRAINT rel_hydr_geom_relation_hydr_geometry DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.mechanical_pretreatment ALTER CONSTRAINT rel_mechanical_pretreatment_infiltration_installation DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.mechanical_pretreatment ALTER CONSTRAINT rel_mechanical_pretreatment_wastewater_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.retention_body ALTER CONSTRAINT rel_retention_body_infiltration_installation DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.hq_relation ALTER CONSTRAINT rel_hq_relation_overflow_char DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.structure_part ALTER CONSTRAINT rel_structure_part_wastewater_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.dryweather_downspout ALTER CONSTRAINT oorel_od_dryweather_downspout_structure_part DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.access_aid ALTER CONSTRAINT oorel_od_access_aid_structure_part DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.dryweather_flume ALTER CONSTRAINT oorel_od_dryweather_flume_structure_part DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.cover ALTER CONSTRAINT oorel_od_cover_structure_part DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.electric_equipment ALTER CONSTRAINT oorel_od_electric_equipment_structure_part DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.electromechanical_equipment ALTER CONSTRAINT oorel_od_electromechanical_equipment_structure_part DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.benching ALTER CONSTRAINT oorel_od_benching_structure_part DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.connection_object ALTER CONSTRAINT rel_connection_object_wastewater_networkelement DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.connection_object ALTER CONSTRAINT rel_connection_object_owner DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.connection_object ALTER CONSTRAINT rel_connection_object_operator DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.building ALTER CONSTRAINT oorel_od_building_connection_object DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.reservoir ALTER CONSTRAINT oorel_od_reservoir_connection_object DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.individual_surface ALTER CONSTRAINT oorel_od_individual_surface_connection_object DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.fountain ALTER CONSTRAINT oorel_od_fountain_connection_object DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.hazard_source ALTER CONSTRAINT rel_hazard_source_connection_object DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.hazard_source ALTER CONSTRAINT rel_hazard_source_owner DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.accident ALTER CONSTRAINT rel_accident_hazard_source DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.substance ALTER CONSTRAINT rel_substance_hazard_source DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.catchment_area ALTER CONSTRAINT rel_catchment_area_wastewater_networkelement_rw_current DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.catchment_area ALTER CONSTRAINT rel_catchment_area_wastewater_networkelement_rw_planned DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.catchment_area ALTER CONSTRAINT rel_catchment_area_wastewater_networkelement_ww_planned DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.catchment_area ALTER CONSTRAINT rel_catchment_area_wastewater_networkelement_ww_current DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.surface_runoff_parameters ALTER CONSTRAINT rel_surface_runoff_parameters_catchment_area DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.measuring_point ALTER CONSTRAINT rel_measuring_point_operator DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.measuring_point ALTER CONSTRAINT rel_measuring_point_waste_water_treatment_plant DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.measuring_point ALTER CONSTRAINT rel_measuring_point_wastewater_structure DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.measuring_point ALTER CONSTRAINT rel_measuring_point_water_course_segment DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.measuring_device ALTER CONSTRAINT rel_measuring_device_measuring_point DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.measurement_series ALTER CONSTRAINT rel_measurement_series_measuring_point DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.measurement_result ALTER CONSTRAINT rel_measurement_result_measuring_device DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.measurement_result ALTER CONSTRAINT rel_measurement_result_measurement_series DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.overflow ALTER CONSTRAINT rel_overflow_wastewater_node DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.overflow ALTER CONSTRAINT rel_overflow_overflow_to DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.overflow ALTER CONSTRAINT rel_overflow_overflow_char DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.overflow ALTER CONSTRAINT rel_overflow_control_center DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.throttle_shut_off_unit ALTER CONSTRAINT rel_throttle_shut_off_unit_wastewater_node DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.throttle_shut_off_unit ALTER CONSTRAINT rel_throttle_shut_off_unit_control_center DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.throttle_shut_off_unit ALTER CONSTRAINT rel_throttle_shut_off_unit_overflow DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.prank_weir ALTER CONSTRAINT oorel_od_prank_weir_overflow DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.pump ALTER CONSTRAINT oorel_od_pump_overflow DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.leapingweir ALTER CONSTRAINT oorel_od_leapingweir_overflow DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.hydraulic_char_data ALTER CONSTRAINT rel_hydraulic_char_data_wastewater_node DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.hydraulic_char_data ALTER CONSTRAINT rel_hydraulic_char_data_overflow_char DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.backflow_prevention ALTER CONSTRAINT oorel_od_backflow_prevention_structure_part DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.backflow_prevention ALTER CONSTRAINT rel_backflow_prevention_throttle_shut_off_unit DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.backflow_prevention ALTER CONSTRAINT rel_backflow_prevention_pump DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.solids_retention ALTER CONSTRAINT oorel_od_solids_retention_structure_part DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.tank_cleaning ALTER CONSTRAINT oorel_od_tank_cleaning_structure_part DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.tank_emptying ALTER CONSTRAINT oorel_od_tank_emptying_structure_part DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.tank_emptying ALTER CONSTRAINT rel_tank_emptying_throttle_shut_off_unit DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.tank_emptying ALTER CONSTRAINT rel_tank_emptying_overflow DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.param_ca_general ALTER CONSTRAINT oorel_od_param_ca_general_surface_runoff_parameters DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.param_ca_mouse1 ALTER CONSTRAINT oorel_od_param_ca_mouse1_surface_runoff_parameters DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.organisation ALTER CONSTRAINT rel_od_organisation_fk_dataowner DEFERRABLE INITIALLY DEFERRED; + +ALTER TABLE qgep_od.organisation ALTER CONSTRAINT rel_od_organisation_fk_dataprovider DEFERRABLE INITIALLY DEFERRED; diff --git a/delta/delta_1.6.2_functions_update_fk_main_cover_main_wastewater_node.sql b/delta/delta_1.6.2_functions_update_fk_main_cover_main_wastewater_node.sql new file mode 100644 index 00000000..0ddd14c3 --- /dev/null +++ b/delta/delta_1.6.2_functions_update_fk_main_cover_main_wastewater_node.sql @@ -0,0 +1,63 @@ + +-------------------------------------------------------- +-- UPDATE wastewater structure fk_main_cover +-- Argument: +-- * obj_id of wastewater structure +-- * all True to update all +-- * omit both arguments to update all where fk_main_cover is null +-------------------------------------------------------- +CREATE OR REPLACE FUNCTION qgep_od.wastewater_structure_update_fk_main_cover(_obj_id text default NULL, _all boolean default false) + RETURNS VOID AS + $BODY$ + DECLARE + myrec record; + +BEGIN + UPDATE qgep_od.wastewater_structure ws + SET fk_main_cover = ws_covers.co_obj_id + FROM ( + SELECT ws.obj_id, min(co.obj_id) OVER (PARTITION BY ws.obj_id) AS co_obj_id + FROM qgep_od.wastewater_structure ws + LEFT JOIN qgep_od.structure_part sp ON sp.fk_wastewater_structure = ws.obj_id + LEFT JOIN qgep_od.cover co ON sp.obj_id = co.obj_id + LEFT JOIN qgep_od.channel ch ON ch.obj_id = ws.obj_id + WHERE ch.obj_id IS NULL AND (_all OR ws.obj_id = _obj_id OR ( NOT _all AND _obj_id is NULL AND ws.fk_main_cover IS NULL)) + ) ws_covers + WHERE ws.obj_id = ws_covers.obj_id; +END + +$BODY$ +LANGUAGE plpgsql +VOLATILE; + +-------------------------------------------------------- +-- UPDATE wastewater structure fk_main_wastewater_node +-- Argument: +-- * obj_id of wastewater structure +-- * all True to update all +-- * omit both arguments to update all where fk_main_wastewater_node is null +-------------------------------------------------------- + +CREATE OR REPLACE FUNCTION qgep_od.wastewater_structure_update_fk_main_wastewater_node(_obj_id text default NULL, _all boolean default false) + RETURNS VOID AS + $BODY$ + DECLARE + myrec record; + +BEGIN + UPDATE qgep_od.wastewater_structure ws + SET fk_main_wastewater_node = ws_nodes.wn_obj_id + FROM ( + SELECT ws.obj_id, min(wn.obj_id) OVER (PARTITION BY ws.obj_id) AS wn_obj_id + FROM qgep_od.wastewater_structure ws + LEFT JOIN qgep_od.wastewater_networkelement ne ON ne.fk_wastewater_structure = ws.obj_id + LEFT JOIN qgep_od.wastewater_node wn ON ne.obj_id = wn.obj_id + LEFT JOIN qgep_od.channel ch ON ch.obj_id = ws.obj_id + WHERE ch.obj_id IS NULL AND (_all OR ws.obj_id = _obj_id OR ( NOT _all AND _obj_id is NULL AND ws.fk_main_wastewater_node IS NULL)) + ) ws_nodes + WHERE ws.obj_id = ws_nodes.obj_id; +END + +$BODY$ +LANGUAGE plpgsql +VOLATILE;