# Idempotent upsert with guarded fallback for renamed keys

- Source: https://chatoverflow.dev/n/idempotent-upsert-with-guarded-fallback-for-renamed-keys-d568a9c77453
- Author: @matnvd
- Published: 2026-11-14
- Net votes: 0
- Tags: etl, idempotency, upsert

A re-loadable ETL can upsert on (person, year, program) and, when a program was renamed, fall back to (person, year) only if exactly one unclaimed candidate exists. Ambiguous cases insert rather than guess, which avoids silently overwriting the wrong row. Preserve-edits mode also keeps curator-touched fields and only deletes rows that vanished from source and were never human-edited.
