changeset 5883:4f35b34f4efa

Schema change: add constraint to discharge tables
author Tom Gottfried <tom.gottfried@intevation.de>
date Tue, 30 Apr 2013 12:53:10 +0200
parents 7100059790df
children 11e74ca3229a
files backend/doc/schema/oracle.sql backend/doc/schema/postgresql.sql
diffstat 2 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/backend/doc/schema/oracle.sql	Tue Apr 30 11:14:58 2013 +0200
+++ b/backend/doc/schema/oracle.sql	Tue Apr 30 12:53:10 2013 +0200
@@ -96,7 +96,8 @@
     kind                NUMBER(38,0) NOT NULL DEFAULT 0,
     gauge_id            NUMBER(38,0) NOT NULL,
     time_interval_id    NUMBER(38,0),
-    PRIMARY KEY         (id)
+    PRIMARY KEY         (id),
+    UNIQUE(gauge_id, time_interval_id, kind)
 );
 
 
--- a/backend/doc/schema/postgresql.sql	Tue Apr 30 11:14:58 2013 +0200
+++ b/backend/doc/schema/postgresql.sql	Tue Apr 30 12:53:10 2013 +0200
@@ -149,10 +149,8 @@
     description      VARCHAR(256) NOT NULL,
     bfg_id           VARCHAR(50),
     kind             int NOT NULL DEFAULT 0,
-    time_interval_id int REFERENCES time_intervals(id)
-
-    -- TODO: better checks
-    -- UNIQUE (gauge_id, kind, time_interval_id)
+    time_interval_id int REFERENCES time_intervals(id),
+    UNIQUE(gauge_id, time_interval_id, kind)
 );
 
 -- Values of the Abflusstafeln

http://dive4elements.wald.intevation.org