mirror of
https://github.com/discourse/discourse.git
synced 2025-04-08 02:00:44 +08:00
DEV: Update reply_to_user_id
after bulk imports (#25289)
This commit is contained in:
parent
6a205ea0a5
commit
1a8cf92be1
@ -335,7 +335,7 @@ def update_user_stats
|
|||||||
end
|
end
|
||||||
|
|
||||||
def update_posts
|
def update_posts
|
||||||
log "Updating posts..."
|
log "Updating post reply counts..."
|
||||||
|
|
||||||
DB.exec <<-SQL
|
DB.exec <<-SQL
|
||||||
WITH Y AS (
|
WITH Y AS (
|
||||||
@ -359,6 +359,19 @@ def update_posts
|
|||||||
# FROM X
|
# FROM X
|
||||||
# WHERE id = X.post_id
|
# WHERE id = X.post_id
|
||||||
# AND COALESCE(reply_to_user_id, -9999) <> X.user_id
|
# AND COALESCE(reply_to_user_id, -9999) <> X.user_id
|
||||||
|
|
||||||
|
log "Updating post reply_to_user_id..."
|
||||||
|
|
||||||
|
DB.exec <<~SQL
|
||||||
|
UPDATE posts AS replies
|
||||||
|
SET reply_to_user_id = replies.user_id
|
||||||
|
FROM posts
|
||||||
|
WHERE posts.topic_id = replies.topic_id
|
||||||
|
AND posts.post_number = replies.reply_to_post_number
|
||||||
|
AND replies.reply_to_post_number IS NOT NULL
|
||||||
|
AND replies.reply_to_user_id IS NULL
|
||||||
|
AND replies.post_number <> replies.reply_to_post_number
|
||||||
|
SQL
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_topics
|
def update_topics
|
||||||
|
Loading…
x
Reference in New Issue
Block a user