From 3254d35078b14655cf3c8a51f443b81534902400 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Tue, 2 Nov 2021 23:27:51 -0400 Subject: [PATCH] FIX: rake categories:move_topics shouldn't move category description topic (#14797) --- lib/tasks/categories.rake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tasks/categories.rake b/lib/tasks/categories.rake index a3d58958929..88430a79513 100644 --- a/lib/tasks/categories.rake +++ b/lib/tasks/categories.rake @@ -14,7 +14,12 @@ task "categories:move_topics", [:from_category, :to_category] => [:environment] if from_category.present? && to_category.present? puts "Moving topics from #{from_category.slug} to #{to_category.slug}..." - Topic.where(category_id: from_category.id).update_all(category_id: to_category.id) + + Topic + .where(category_id: from_category.id) + .where.not(id: from_category.topic_id) + .update_all(category_id: to_category.id) + from_category.update_attribute(:topic_count, 0) puts "Updating category stats..."