diff schema/gemma.sql @ 1825:484ae4fe09d7

Backed out changeset 332e42a2088d (no staging needed).
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 16 Jan 2019 12:42:34 +0100
parents 4d23461bea4d
children d4e2637eed58
line wrap: on
line diff
--- a/schema/gemma.sql	Wed Jan 16 12:42:19 2019 +0100
+++ b/schema/gemma.sql	Wed Jan 16 12:42:34 2019 +0100
@@ -236,8 +236,7 @@
     )
 
     CREATE TABLE gauges (
-        id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
-        location isrs UNIQUE NOT NULL KEY CHECK(
+        location isrs PRIMARY KEY CHECK(
             (location).orc SIMILAR TO 'G[[:digit:]]{4}'
             AND CAST(substring((location).orc from 2 for 4) AS int) < 2048),
         objname varchar NOT NULL,
@@ -257,7 +256,7 @@
         FOR EACH ROW EXECUTE PROCEDURE update_date_info()
 
     CREATE TABLE gauges_reference_water_levels (
-        gauge_id isrs NOT NULL REFERENCES gauges(location),
+        gauge_id isrs NOT NULL REFERENCES gauges,
         reference_water_level varchar(20)
             NOT NULL REFERENCES reference_water_levels,
         PRIMARY KEY (gauge_id, reference_water_level),
@@ -266,7 +265,7 @@
 
     CREATE TABLE gauge_measurements (
         id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
-        fk_gauge_id isrs NOT NULL REFERENCES gauges(location),
+        fk_gauge_id isrs NOT NULL REFERENCES gauges,
         measure_date timestamp with time zone NOT NULL,
         country_code char(2) NOT NULL REFERENCES countries,
         -- TODO: add relations to stuff provided as enumerations
@@ -407,7 +406,7 @@
     CREATE TABLE bottlenecks (
         id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
         bottleneck_id varchar UNIQUE NOT NULL,
-        fk_g_fid isrs NOT NULL REFERENCES gauges(location),
+        fk_g_fid isrs NOT NULL REFERENCES gauges,
         -- XXX: DRC references "ch. 3.1.1", which does not exist in document.
         objnam varchar,
         nobjnm varchar,