Reconsider user of `upsert` on member creation for organization_users creation
Consider use of upsert
in regards to db perf and sequential ID reservations
The following discussion from !141500 (merged) should be addressed:
-
@DylanGriffith started a discussion: (+4 comments) Thought (non-blocking): It's kinda hard for me to see any need for
upsert
over acreate_or_find_by
here. Or anupsert on conflict do nothing
. Looking at the generated query it has extra logic to update the other fields. Considering this is only called in anafter_create_commit
it shouldn't even be technically possible to have a race condition that results in this already existing for the user. Longer term I can see us possibly wanting to ensure it exists in case the first create failed (and possibly as part of backfilling it) but in it's current state I'm not sureupsert
helps. I knowupsert
is making the query look at little strange but other than that I don't know if there is any performance implications either way here.