[Lada-commits] [PATCH 3 of 3] Add necessary constraints for status workflow

Wald Commits scm-commit at wald.intevation.org
Mon Feb 8 18:31:31 CET 2016


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1454952668 -3600
# Node ID e161d8f2d9783e725e11bd1fa66c02da5be35a25
# Parent  53d739275c5078d95c13530bfa586eb6259cec4e
Add necessary constraints for status workflow.

diff -r 53d739275c50 -r e161d8f2d978 db_schema/stammdaten_schema.sql
--- a/db_schema/stammdaten_schema.sql	Mon Feb 08 18:23:41 2016 +0100
+++ b/db_schema/stammdaten_schema.sql	Mon Feb 08 18:31:08 2016 +0100
@@ -98,7 +98,7 @@
 
 CREATE TABLE auth_funktion (
     id smallint PRIMARY KEY,
-    funktion character varying(40)
+    funktion character varying(40) UNIQUE NOT NULL
 );
 INSERT INTO auth_funktion VALUES (0, 'Erfasser');
 INSERT INTO auth_funktion VALUES (1, 'Status-Erfasser');
@@ -868,7 +868,7 @@
 -- Status workflow
 CREATE TABLE status_stufe (
     id integer PRIMARY KEY,
-    stufe character varying(50)
+    stufe character varying(50) UNIQUE NOT NULL
 );
 INSERT INTO status_stufe VALUES (1, 'MST');
 INSERT INTO status_stufe VALUES (2, 'LAND');
@@ -877,7 +877,7 @@
 
 CREATE TABLE status_wert (
     id integer PRIMARY KEY,
-    wert character varying(50)
+    wert character varying(50) UNIQUE NOT NULL
 );
 INSERT INTO status_wert VALUES (0, 'nicht vergeben');
 INSERT INTO status_wert VALUES (1, 'plausibel');
@@ -890,8 +890,9 @@
 
 CREATE TABLE status_kombi (
     id integer PRIMARY KEY,
-    stufe_id integer REFERENCES status_stufe,
-    wert_id integer REFERENCES status_wert
+    stufe_id integer REFERENCES status_stufe NOT NULL,
+    wert_id integer REFERENCES status_wert NOT NULL,
+    UNIQUE(stufe_id, wert_id)
 );
 -- 'zurückgesetzt' is left out here deliberately!
 INSERT INTO status_kombi VALUES (1, 1, 0);
@@ -912,8 +913,9 @@
 CREATE SEQUENCE status_reihenfolge_id_seq;
 CREATE TABLE status_reihenfolge (
     id integer PRIMARY KEY DEFAULT nextval('status_reihenfolge_id_seq'),
-    von_id integer REFERENCES status_kombi,
-    zu_id integer REFERENCES status_kombi
+    von_id integer REFERENCES status_kombi NOT NULL,
+    zu_id integer REFERENCES status_kombi NOT NULL,
+    UNIQUE(von_id, zu_id)
 );
 
 CREATE FUNCTION populate_status_reihenfolge() RETURNS void AS $$


More information about the Lada-commits mailing list