Mercurial > gemma
changeset 5155:20f338cb4d48
Add forgotten cleanup of fairway dimensions
This is actually a fixup of rev. e21cbb9768a2, that added database
schema version 1431 with a constraint trigger preventing new or
updated rows to have a duplicate area but missed to cleanup existing
data. So cleanup now, before the duplicates hurt in future imports
that try to keep the duplicates in history.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 01 Apr 2020 19:01:08 +0200 |
parents | a33f1d51d1b7 |
children | 0897859b2f4a f742b5cf9a64 |
files | schema/updates/1438/01.remove_duplicate_fairway_areas.sql schema/version.sql |
diffstat | 2 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/updates/1438/01.remove_duplicate_fairway_areas.sql Wed Apr 01 19:01:08 2020 +0200 @@ -0,0 +1,9 @@ +-- Remove entries that do not suffice the requirements set out by the +-- constraint trigger on fairway_dimensions, but that could be left over +-- from an import run before the constraint trigger was in place +DELETE FROM waterway.fairway_dimensions fd + USING waterway.fairway_dimensions fd_self + WHERE ST_Equals(CAST(fd.area AS geometry), CAST(fd_self.area AS geometry)) + AND fd.validity && fd_self.validity + AND fd.staging_done = fd_self.staging_done + AND fd.id < fd_self.id