Is it ok to update external_id on discourse database?

I 've been searching the forum for info on updating external_id on discourse db.

found this topic interesting:

Still I was interested in some insights regarding the implications of updating the external_id on the database.

could I just issue an sql update and set the new correct external_id? can that bring any hidden problems? like if the user has a current open session or something else?

I got the users created through sso using an external_id that’s the user’s account id on the external system. (I may need to model something else but it would be cool to be able to avoid changing the external system model at least for now)

the problem for me is that the person may have more than one account on the external system and can merge those accounts into one so sometimes depending on how he merges a new external_id can come for the same user/email.

I am using the require_activation option so as I 've read on the mentioned topic I can’t delete the record and wait for it to be recreated.

thank you

Yes, you should be able to do that, but you should fix the real problem first

for instance when accounts are being merged always make sure the lowest ID is assigned / used.

3 Likes

Yes… during external account merges I am respecting the oldest account… but sometimes that’s not what I need.

some accounts interact with the forum (type A, letsay) and some other accounts are not meant for that (type B).

so if they first create a type B account…
and later they create a type A account, they do sso with it on the forum

and later they merge A & B and honor the oldest account which has a different external_id

so yes…
I need to come up with a solution for my external system thingy…

but I think I will setup a daily cron that checks if any of this happened and fixup the external_ids for the moment.

thank you!

In that case you could either

a) synchronize all accounts to discourse using the SSO sync mechanism
b) keep track of which accounts have been used to log in to Discourse
or
c) when you merge, do an external ID lookup to determine which account(s) have been used with Discourse

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.