I have been doing some testing of importing content and it didn’t go as hoped - so I’d like to delete all the content and try again. Is there a way to wipe out an entire category of topics and posts?
Probably something like this in the
c = Category.find(5) #<Category id: 5, name: meta, ...> Topic.where(category: c).delete
A bit trickier that that, I am pretty sure it will not cascade.
Yeah, I was wondering about that. What does the admin “delete topic” button do? Maybe the script could call that code for every topic in the category instead.
What about this using the api…
Get a list of all users.
Loop through all users
That should be scriptable in any language
Oh, didn’t see that part…
@tobiaseigen you could also
cd /var/docker followed by
rm -rf shared/postgres_* to wipe all the data from a Docker install.
Next time, you can probably streamline the process by taking a backup, testing import, then reverting by restoring the backup.
Of course the ‘backup’ could be the shared folder or a Discourse backup.
Yes, but that would nuke all the other settings and users as well, right? I just want to nuke the content in those categories.
Now you tell me. Actually, I realized that myself already and for next time will take snapshot backups before doing crazy stuff…