qwat / qwat-data-model

TEKSI Water module (project QWAT) - PostgreSQL / postgis Datamodel
https://www.teksi.ch
23 stars 24 forks source link

Set pipe year check >= 1800 instead > 1800 and add some verbosity in init_qwat.sh #366

Closed nicolas-sitylb closed 1 year ago

nicolas-sitylb commented 1 year ago
ponceta commented 1 year ago

A delta is required with this code :

ALTER TABLE qwat_od.pipe DROP CONSTRAINT pipe_year_check ;

ALTER TABLE qwat_od.pipe ADD CONSTRAINT pipe_year_check CHECK (year IS NULL OR year >= 1800 AND (year <= EXTRACT(YEAR FROM NOW()) OR fk_status = 1306 AND year - 50 <= EXTRACT(YEAR FROM NOW())));

https://stackoverflow.com/questions/13244889/how-to-alter-constraint

olivierdalang commented 1 year ago

Hmm pum check should have failed without the delta, no ?

ponceta commented 1 year ago

To my knowledge, pum check the existence but not the syntax of constraints.

See :

https://github.com/opengisch/pum/blob/master/pum/core/checker.py#L178

olivierdalang commented 1 year ago

Ok, opened an issue here : https://github.com/opengisch/pum/issues/103

IMO worth looking into as there may be inconsistencies in constraints btw the datamodel and an upgraded datamodel, which could be serious in terms of data integrity