Is it ok to update external_id on discourse database?

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.