Mercurial > gemma
diff schema/gemma.sql @ 1572:056a86b24be2
Made bottleneck primary key an int. Attention: This may break something!
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 12 Dec 2018 19:21:02 +0100 |
parents | d4b7a6d054cd |
children | caedd9b176f2 |
line wrap: on
line diff
--- a/schema/gemma.sql Wed Dec 12 17:21:11 2018 +0100 +++ b/schema/gemma.sql Wed Dec 12 19:21:02 2018 +0100 @@ -402,7 +402,8 @@ -- (minOccurs=0; nillable seems to be set arbitrarily as even bottleneck_id and -- fk_g_fid (both mandatory, i.e. marked "M" in DRC) have nillable="true" in WSDL) CREATE TABLE bottlenecks ( - bottleneck_id varchar PRIMARY KEY, + id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, + bottleneck_id varchar UNIQUE NOT NULL, fk_g_fid isrs NOT NULL REFERENCES gauges, -- XXX: DRC references "ch. 3.1.1", which does not exist in document. objnam varchar, @@ -431,7 +432,7 @@ FOR EACH ROW EXECUTE PROCEDURE update_date_info() CREATE TABLE bottlenecks_riverbed_materials ( - bottleneck_id varchar REFERENCES bottlenecks, + bottleneck_id int REFERENCES bottlenecks(id), riverbed varchar REFERENCES riverbed_materials, -- XXX: should be 'natsur' according to IENC Encoding Guide M.4.3 PRIMARY KEY (bottleneck_id, riverbed) @@ -439,7 +440,7 @@ CREATE TABLE sounding_results ( id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, - bottleneck_id varchar NOT NULL REFERENCES bottlenecks, + bottleneck_id int NOT NULL REFERENCES bottlenecks(id), date_info date NOT NULL, UNIQUE (bottleneck_id, date_info), area geography(POLYGON, 4326) NOT NULL, @@ -476,7 +477,7 @@ CREATE TABLE fairway_availability ( id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, position_code char(2) REFERENCES position_codes, - bottleneck_id varchar NOT NULL REFERENCES bottlenecks, + bottleneck_id int NOT NULL REFERENCES bottlenecks(id), surdat date NOT NULL, UNIQUE (bottleneck_id, surdat), -- additional_data xml -- Currently not relevant for GEMMA @@ -539,7 +540,7 @@ FROM waterway.bottlenecks bn LEFT JOIN ( SELECT bottleneck_id, max(date_info) AS current FROM waterway.sounding_results - GROUP BY bottleneck_id) sr ON sr.bottleneck_id = bn.bottleneck_id + GROUP BY bottleneck_id) sr ON sr.bottleneck_id = bn.id ORDER BY objnam CREATE TABLE import_configuration (