What
The unique index place_osm that we have defined on socialmaps.place (osm_type, osm_id) was causing issues when an existing place was renamed.
Why
For example, Node #349283463 was renamed from "Coffee Dock" to "Insomnia" in changeset #182673214. This meant that there were no matching socialmaps.place for the updated osm2pgsql.element with the new name (since we're matching places to elements using name + location). When socialmaps-api tried to create a new place for the given element returned in the resultset, it got a database error for trying to violate the uniqueness constraint of the index.
Notes
We need to invest into handling changes to elements in the context of "place permanence". For instance, should the aforementioned rename ("Coffee Dock" → "Insomnia") result in a new place (I think so) or should we treat it as the same cafe and move its existing reviews over? There are no reviews of it at the moment, but we'll have to have a policy around such changes for future.
## What
The unique index `place_osm` that we have defined on `socialmaps.place (osm_type, osm_id)` was causing issues when an existing place was renamed.
## Why
For example, [Node #349283463](https://www.openstreetmap.org/node/349283463) was renamed from "Coffee Dock" to "Insomnia" in [changeset #182673214](https://www.openstreetmap.org/changeset/182673214). This meant that there were no matching `socialmaps.place` for the updated `osm2pgsql.element` with the new name (since we're matching places to elements using name + location). When `socialmaps-api` tried to create a new `place` for the given `element` returned in the resultset, it got a database error for trying to violate the uniqueness constraint of the index.
## Notes
We need to invest into handling changes to elements in the context of "place permanence". For instance, should the aforementioned rename ("Coffee Dock" → "Insomnia") result in a new place (I think so) or should we treat it as the same cafe and move its existing reviews over? There are no reviews of it at the moment, but we'll have to have a policy around such changes for future.