orma / openroads-vn-analytics

BSD 2-Clause "Simplified" License
0 stars 1 forks source link

Wrap write to `field_data_geometries` in a transaction during RLP upload #469

Open batpad opened 6 years ago

batpad commented 6 years ago

Currently, we perform the insert into the field_data_geometries table before creating and committing the changeset for the ways that need to be added as part of the import, here: https://github.com/orma/openroads-vn-api/blob/master/routes/rlp.js#L61

We should either do that insert after the changeset upload suceeds, or wrap everything in a single postgres transaction. Currently, if there is an error with the changeset upload, the data will already exist in field_data_geometries, preventing attempts at re-upload.

cc @geohacker

batpad commented 6 years ago

Something like this should work: https://knexjs.org/#Builder-transacting - going to give it a shot.