Bulk delete suspended users after import

After converting a phpBB forum, I have ~700 suspended users. I’d like to delete the ones that also have no posts or topics.

Is there a rails command for that?

Sure @vinothkannans can advise you on this.

2 Likes

For that, you should enter into the container with

./launcher enter app

Then, you will need to launch the rails console with

rails c

Once you’re in the rails console, you can delete all suspended users who have zero posts and topics with

User.joins(:user_stat).where("users.suspended_at IS NOT NULL AND user_stats.topic_count = 0 AND user_stats.post_count = 0").destroy_all

Always make sure you have latest db backup whenever you run destroy_all method.

13 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.