Postgres upsert with complex logic before update
I’m looking for a method to perform an upsert on a Postgres table but with some complex logic applied to the update based on the existing column value. Essentially I think I need some sort of combination of: