One of the Discourse sites that I operate is preparing to undergo a re-launch, and due to the large amount of inactivity on the forum, and the type of posts that have been made in the last year or so, I’d like to remove/delete all topics and start over fresh on the forums.
The easiest way is to use rails command line, ssh into your server and then
cd /var/discourse
./launcher enter app
rails c
Post.where("user_id > 0").where(post_number: 1).find_each do |post|
PostDestroyer.new(Discourse.system_user, post).destroy
putc "."
end
be sure to make a backup before running this destructive code.
Does running PostDestroyer.destroy actually remove the record from the database or does it merely mark the post as deleted, keeping it in the database?
There will be a lot of uses for a script that actually DELETES all the topics and posts, leaving everything (like site settings and users) there. Categories are yes/no.
Keep all site structure, (categories, groups, users, and settings), but wipe all threads, and PMS, and logs, basically to take a demo site that served as a sandbox, and transition it to a live site, similar to the OP, without having to setup a new instance and re-register all my users. But everything content wise, as well as logged actions all starts fresh.
Does this rake task posted above do this, or can the added reset logs as well be done, so all post data, and all log data is wiped fresh?
È davvero utile, grazie mille. Sembra che questo non rimuova i Campi Personalizzati dei post. Nel mio caso, sto cercando di importare post, quindi i campi personalizzati “import_id” rimangono, facendo credere all’importatore che i post siano ancora presenti, anche se non lo sono. C’è un modo per rimuovere anche i dati dei campi personalizzati?