mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
FIX: prevents duplicate error on instragam migration (#7178)
Previous instagram records didn’t have unique index, as a result it's seems like in some cases we have duplicate ids, which is causing issues with the associated_accounts which does have unique index. It's sorted by `updated_at DESC` on the thought that the most recent one is more likely to be the one we want to keep.
This commit is contained in:
parent
a6a52d1523
commit
93490fbfaf
@ -9,15 +9,19 @@ class MigrateInstagramUserInfo < ActiveRecord::Migration[5.2]
|
||||
last_used,
|
||||
created_at,
|
||||
updated_at
|
||||
) SELECT
|
||||
'instagram',
|
||||
instagram_user_id,
|
||||
user_id,
|
||||
json_build_object('nickname', screen_name),
|
||||
updated_at,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM instagram_user_infos
|
||||
)
|
||||
SELECT
|
||||
'instagram',
|
||||
instagram_user_id,
|
||||
user_id,
|
||||
json_build_object('nickname', screen_name),
|
||||
updated_at,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM instagram_user_infos
|
||||
ORDER BY updated_at DESC
|
||||
ON CONFLICT (provider_name, provider_uid)
|
||||
DO NOTHING
|
||||
SQL
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user