comparison pkg/imports/dmv.go @ 2380:5f300bd7316f

Do not delete distance marks on import Deleting a distance mark will fail if other objects (e.g. waterway profiles) depend on it. Since the following INSERT is actually an 'UPSERT', existing distance marks will be updated anyhow. Deletion of distance marks that have been removed from the RIS-Index still has to be implemented.
author Tom Gottfried <tom@intevation.de>
date Fri, 22 Feb 2019 15:15:23 +0100
parents 7c83b5277c1c
children eb1d119f253f
comparison
equal deleted inserted replaced
2379:f04d33fec01e 2380:5f300bd7316f
64 64
65 // CleanUp does nothing as there is nothing to cleanup with distance marks virtual. 65 // CleanUp does nothing as there is nothing to cleanup with distance marks virtual.
66 func (*DistanceMarksVirtual) CleanUp() error { return nil } 66 func (*DistanceMarksVirtual) CleanUp() error { return nil }
67 67
68 const ( 68 const (
69 deleteDistanceMarksVirtualSQL = `
70 DELETE FROM waterway.distance_marks_virtual
71 WHERE (location_code).country_code = $1
72 `
73 insertDistanceMarksVirtualSQL = ` 69 insertDistanceMarksVirtualSQL = `
74 INSERT INTO waterway.distance_marks_virtual ( 70 INSERT INTO waterway.distance_marks_virtual (
75 location_code, 71 location_code,
76 geom, 72 geom,
77 related_enc 73 related_enc
135 if err != nil { 131 if err != nil {
136 log.Printf("error: %v\n", err) 132 log.Printf("error: %v\n", err)
137 return nil, fmt.Errorf("Error requesting ERDMS service: %v", err) 133 return nil, fmt.Errorf("Error requesting ERDMS service: %v", err)
138 } 134 }
139 135
140 if _, err := tx.ExecContext(ctx, deleteDistanceMarksVirtualSQL, country); err != nil {
141 return nil, err
142 }
143
144 insertStmt, err := tx.PrepareContext(ctx, insertDistanceMarksVirtualSQL) 136 insertStmt, err := tx.PrepareContext(ctx, insertDistanceMarksVirtualSQL)
145 if err != nil { 137 if err != nil {
146 return nil, err 138 return nil, err
147 } 139 }
148 defer insertStmt.Close() 140 defer insertStmt.Close()