Delete all users and posts


(Thomas Wilson) #1

Hi folks,

Is there a way for me to delete all users and/or associated content from a discourse installation, without reinstalling from scratch? We’d essentially like a fresh install of discourse but with the previous settings maintained (e.g. smtp settings, logos, s3 etc. etc.)

We could probably do this directly in the postgres DB, but I wanted to check if anyone had any pre-canned SQL we could lift, or if there’s a script which does this for us.

Also – sidenote: when i got a user page in the admin panel, it is blank. Not sure if this is a known bug?

Thanks


(Sam Saffron) #2

no trivial way to do this, I guess you could truncate all tables except for site_settings and nuke the uploads directory.


(Thomas Wilson) #3

Thanks, I’ll give this a go


(Jeff Atwood) #4

Let us know if that works OK.


(Thomas Wilson) #5

Sure - will do. Out of interest, how do you reset try.discourse on a daily basis? Do you rebuild the docker container and simply re-insert the site settings?


(Sam Saffron) #6

Much simpler, we just restore it from backup daily.


(Jeff Atwood) #7

Did this work for you?


(Thomas Wilson) #8

We ended up simply dumping the site_settings table and re-installing on a new DO droplet - a bit cleaner that way :smile:


(colin avolve) #9

Just wondering if another, more elegant apporach, has become available for this?


(Blake Erickson) #10

I just wrote a little ruby app that does this using the API. Just posting here in case anyone needs to do this and as a reminder for me to update the discourse_api gem with the endpoints to do this.