Mercurial > lada > lada-server
diff db_schema/lada_schema.sql @ 1126:70b51893f15b
Fix UNIQUE-constraint and respective validation.
Btw. improved readability of DEFAULT definition.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Mon, 31 Oct 2016 18:09:45 +0100 |
parents | 1ef08710aaeb |
children | 48c0132dbc85 |
line wrap: on
line diff
--- a/db_schema/lada_schema.sql Mon Oct 31 17:14:49 2016 +0100 +++ b/db_schema/lada_schema.sql Mon Oct 31 18:09:45 2016 +0100 @@ -192,7 +192,10 @@ CREATE TABLE probe ( id serial PRIMARY KEY, - id_alt character varying(20) DEFAULT (('sss'::text || lpad(((nextval('land.probe_probe_id_seq'::regclass))::character varying)::text, 12, '0'::text)) || 'Y'::text) NOT NULL, + id_alt character varying(20) UNIQUE NOT NULL + DEFAULT 'sss' + || lpad(nextval('land.probe_probe_id_seq')::varchar, 12, '0') + || 'Y', test boolean DEFAULT false NOT NULL, mst_id character varying(5) NOT NULL REFERENCES stammdaten.mess_stelle, labor_mst_id character varying(5) NOT NULL REFERENCES stammdaten.mess_stelle, @@ -214,7 +217,7 @@ solldatum_beginn timestamp without time zone, solldatum_ende timestamp without time zone, tree_modified timestamp without time zone DEFAULT now(), - UNIQUE (mst_id, hauptproben_nr, id_alt), + UNIQUE (mst_id, hauptproben_nr), CHECK(solldatum_beginn <= solldatum_ende) ); CREATE TRIGGER letzte_aenderung_probe BEFORE UPDATE ON probe FOR EACH ROW EXECUTE PROCEDURE update_letzte_aenderung();