From 90edaec9f0ac304f6ff6b35232d31418d5cb4158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Wed, 14 May 2014 19:46:47 +0200 Subject: [PATCH] BUGFIX: make sure we properly set topics.last_posted_at when importing from Vanilla --- lib/tasks/vanilla.thor | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/tasks/vanilla.thor b/lib/tasks/vanilla.thor index bb86ca8f791..59170be2051 100644 --- a/lib/tasks/vanilla.thor +++ b/lib/tasks/vanilla.thor @@ -240,14 +240,15 @@ class Vanilla < Thor @discussions.each do |discussion| next unless topic_id = discussion[:new_id] - # HACK to make sure bumped_at is properly set + # HACK: make sure both bumped_at and last_posted_at are properly set sql = <<-SQL UPDATE topics SET views = :views, closed = :closed, pinned_at = :pinned_at, - bumped_at = (SELECT created_at FROM posts WHERE topic_id = :topic_id ORDER BY created_at DESC LIMIT 1) + last_posted_at = (SELECT MAX(created_at) FROM posts WHERE topic_id = :topic_id) + bumped_at = (SELECT MAX(created_at) FROM posts WHERE topic_id = :topic_id) WHERE id = :topic_id SQL