A platform for community discussion. Free, open, simple.
FIX: mark posted as true for post authors in the TopicUser table during ensure_consistency task (#20473)
Constanzac05199209889
diff --git a/lib/tasks/import.rake b/lib/tasks/import.rakeindex ed6bdc25ce6..aad8637404c 100644--- a/lib/tasks/import.rake+++ b/lib/tasks/import.rake@@ -22,6 +22,7 @@ task "import:ensure_consistency" => :environment doupdate_usersupdate_groupsupdate_tag_stats+ update_topic_userscreate_category_definitionslog "Done!"@@ -29,6 +30,10 @@ endMS_SPEND_CREATING_POST ||= 5000+# -- TODO: We need to check the queries are actually adding/updating the necessary+# data, post migration. The ON CONFLICT DO NOTHING may cause the clauses to be ignored+# when we actually need them to run.+def insert_post_timingslog "Inserting post timings..."@@ -415,6 +420,29 @@ def update_tag_statsTag.ensure_consistency!end+def update_topic_users+ log "Updating topic users..."++ DB.exec <<-SQL+ WITH X AS (+ SELECT p.topic_id+ , p.user_id+ FROM posts p+ JOIN topics t ON t.id = p.topic_id+ WHERE p.deleted_at IS NULL+ AND t.deleted_at IS NULL+ AND NOT p.hidden+ AND t.visible+ )+ UPDATE topic_users tu+ SET posted = 't'+ FROM X+ WHERE tu.topic_id = X.topic_id+ AND tu.user_id = X.user_id+ AND posted = 'f'+ SQL+end+def create_category_definitionslog "Creating category definitions"Category.ensure_consistency!