Unable to delete all user's post (error 502)

I’ve found this topic reporting the same issue and I believe I’m facing the same situation

The user requested their post to be deleted but I’m sure he posted in some megatopic.
Since we migrated from vbulleting, megatopic weren’t really a problem and we have some with 50k replies and counting.

Of course, since the migration to discourse, the settings are to lock and create a new topic when one reach 5000 replies.

Is there someone that can help me with a rake task or some ruby function to run that will delete all posts from a user?

Thank you

I think you can start from here: How to delete thousands of Private Messages? - #7 by RGJ

I guess there’s no need to say… Do a backup first (and now it’s said :stuck_out_tongue: )!