Skip to content

Commit

Permalink
fix(fkeys): add foreign keys to sector_id and muni_id
Browse files Browse the repository at this point in the history
  • Loading branch information
mguzman14 committed Aug 27, 2024
1 parent b433f6e commit 0f68568
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
7 changes: 6 additions & 1 deletion updates/36/36012/ud/tablect.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ SET search_path = SCHEMA_NAME, public, pg_catalog;


ALTER TABLE sys_style ADD CONSTRAINT sys_style_pkey PRIMARY KEY (layername, styleconfig_id);
ALTER TABLE sys_style ALTER COLUMN styleconfig_id SET NOT NULL;
ALTER TABLE sys_style ALTER COLUMN styleconfig_id SET NOT NULL;

ALTER TABLE drainzone ADD CONSTRAINT drainzone_sector_id_fkey FOREIGN KEY (sector_id) REFERENCES sector(sector_id);
ALTER TABLE dma ADD CONSTRAINT dma_muni_id_fkey FOREIGN KEY (sector_id) REFERENCES sector(sector_id);

ALTER TABLE raingage ADD CONSTRAINT raingage_muni_id FOREIGN KEY (muni_id) REFERENCES ext_municipality(muni_id);
12 changes: 12 additions & 0 deletions updates/36/36012/utils/tablect.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,15 @@ SET search_path = SCHEMA_NAME, public, pg_catalog;

ALTER TABLE sys_style ADD CONSTRAINT sys_style_styleconfig_id_fk FOREIGN KEY (styleconfig_id) REFERENCES config_style(id);

ALTER TABLE samplepoint ADD CONSTRAINT samplepoint_muni_id FOREIGN KEY (muni_id) REFERENCES ext_municipality(muni_id);
ALTER TABLE samplepoint ADD CONSTRAINT samplepoint_sector_id FOREIGN KEY (sector_id) REFERENCES sector(sector_id);

ALTER TABLE element ADD CONSTRAINT element_muni_id FOREIGN KEY (muni_id) REFERENCES ext_municipality(muni_id);
ALTER TABLE element ADD CONSTRAINT element_sector_id FOREIGN KEY (sector_id) REFERENCES sector(sector_id);

ALTER TABLE link ADD CONSTRAINT link_muni_id FOREIGN KEY (muni_id) REFERENCES ext_municipality(muni_id);
ALTER TABLE link ADD CONSTRAINT link_sector_id FOREIGN KEY (sector_id) REFERENCES sector(sector_id);

ALTER TABLE dimensions ADD CONSTRAINT dimensions_muni_id FOREIGN KEY (muni_id) REFERENCES ext_municipality(muni_id);
ALTER TABLE dimensions ADD CONSTRAINT dimensions_sector_id FOREIGN KEY (sector_id) REFERENCES sector(sector_id);

11 changes: 10 additions & 1 deletion updates/36/36012/ws/tablect.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,13 @@ ALTER TABLE sys_style ADD CONSTRAINT sys_style_pkey PRIMARY KEY (layername, styl
ALTER TABLE sys_style ALTER COLUMN styleconfig_id SET NOT NULL;

ALTER TABLE element ADD CONSTRAINT element_brand_id FOREIGN KEY (brand_id) references cat_brand(id);
ALTER TABLE element ADD CONSTRAINT element_model_id FOREIGN KEY (model_id) references cat_brand_model(id);
ALTER TABLE element ADD CONSTRAINT element_model_id FOREIGN KEY (model_id) references cat_brand_model(id);

ALTER TABLE pond ADD CONSTRAINT pond_muni_id FOREIGN KEY (muni_id) REFERENCES ext_municipality(muni_id);
ALTER TABLE "pool" ADD CONSTRAINT pool_muni_id FOREIGN KEY (muni_id) REFERENCES ext_municipality(muni_id);


ALTER TABLE presszone ADD CONSTRAINT presszone_sector_id FOREIGN KEY (sector_id) REFERENCES sector(sector_id);
ALTER TABLE dma ADD CONSTRAINT dma_sector_id FOREIGN KEY (sector_id) REFERENCES sector(sector_id);
ALTER TABLE dqa ADD CONSTRAINT dqa_sector_id FOREIGN KEY (sector_id) REFERENCES sector(sector_id);

0 comments on commit 0f68568

Please sign in to comment.