Auto-close old topics from a migrated forum

I would SSH into the server and then

cd /var/discourse
./launcher enter app
rails c
Topic.where(closed: false).where("created_at < '2015-01-01'").find_each do |topic| 
  topic.update_status("closed", true, Discourse.system_user)
end

And you should have all the topics created before January 1st 2015 closed :wink:

12 Likes