Mercurial > gemma
view schema/updates/1426/01.historicise_axis.sql @ 5677:a57be8bfb6ea sr-v2
More suited file names.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 11 Feb 2024 09:51:21 +0100 |
parents | e8661379a6c5 |
children |
line wrap: on
line source
ALTER TABLE waterway.waterway_axis ADD validity tstzrange NOT NULL DEFAULT tstzrange(current_timestamp, NULL) CHECK (NOT isempty(validity)), ADD last_found timestamp with time zone NOT NULL DEFAULT current_timestamp; -- Assume existing entries have been valid since last successful import UPDATE waterway.waterway_axis SET validity = tstzrange( (SELECT max(changed) FROM import.imports WHERE kind = 'wx' AND state = CAST('accepted' AS import_state)), NULL); DROP TRIGGER waterway_axis_wtwaxs_unique ON waterway.waterway_axis; CREATE CONSTRAINT TRIGGER waterway_axis_wtwaxs_unique AFTER INSERT OR UPDATE OF wtwaxs, validity ON waterway.waterway_axis FOR EACH ROW EXECUTE FUNCTION prevent_st_equals('wtwaxs', 'validity'); CREATE INDEX waterway_axis_validity ON waterway.waterway_axis USING GiST (validity); -- No more need to delete DROP POLICY responsibility_area_delete ON waterway.waterway_axis;