The proper way to completely delete hundred of topics via rails?

Interesting… we are missing a dependant destroy here, I am not sure why.

https://github.com/discourse/discourse/blob/master/app/models/topic.rb#L119

Easy to fix though

Post.where('topic_id not in (select id from topics)').limit(100).destroy_all

And repeat… till no results.

5 Likes