How can I delete or undelete topics?

The downtime let me do some testing and watch a bit of the Build 2016 livestream

On my localhost a member created a topic and then - no replies had been made to it yet - a Moderator account deleted it.

To see it logged in as Admin I needed to go to
thesite/latest?status=deleted to see it.

Once there I needed to use the topic admin wrench


Thanks for taking the time to write that up. But I’ve gotten that far.

The problem is that the posts will fail to be undeleted.

This is what Discourse throws up in the console:

Any help would be much appreciated.

Edit: this is in Chrome Incognito with the current user being the owner of topic.

Can you expand the PUT error and do you see anything related in

Nope. Does anything else look interesting?

That is bizarre, as that should be generating something in the Admin > Logs > Error Logs (which is actually located at /logs). As that 500 Internal Server Error is an error on the backend.

Continuing the discussion from Embedding Discourse Comments via Javascript:

@eviltrout Can you please elaborate a little bit? Other forum users have suggested I’ve stumbled into a bug.

Yes and it’s fine.

I work for a higher education consortium. The private Discourse is a forum for the members of that consortium (a few hundred users at present). The comments are for our public blog but on our site they’re only visible to members. I also plan to use the embedding system for other content as well. The idea is to allow members to quickly open a discussion on a blog post, an event, or other piece of content. That’s why, ideally, I wouldn’t want to create entries for all the new content.

P.S. The original thread was closed and I could not reply.

I’m not sure if you’ve hit a bug or not, but I suspect it is related to the TopicEmbed table. Since you can’t recover the topics, I suspect you remove all the entries in the topic_embeds table via the database console, then let embedding recreate the topics.

Just to be clear, you are aware that you can’t post via embedding right? It’s only for displaying. It’s usually meant to attract people to the forum content.


I feel daft for asking, but I’m not able to find any documentation on how to do this. Any pointers?

Yep. I realise that. That’s why I’m more interested in a gateway button like “Discuss in our forum”, that take the user to a new topic, populated with content from the site, or to an existing topic, if it’s already been created. (Because our Discourse is private anyway and only logged in users would be able to see the posts on the site.)

There is no documentation for this unfortunately, as it is quite an advanced repair technique. I’m not sure how you’ve installed discourse but if you access the database you’ll want to issue a DELETE FROM topic_embeds - of course be warned that will remove all existing links between posts and embeddings. So if you have any in a good state they will be removed too.


I have three posts that were somehow undeleted, while all the rest are deleted (and refuse to be undeleted). I’m perfectly happy to deleted the three and unlinking them.

This would allow me to link me to create new topics based on the same blog posts, right?

If so, I’d like to try this.

My Discourse uses the vanilla Docker install in a Digital Ocean droplet. I have a local Vagrant version, which I’ve used to run experiments. For obvious reasons, I would liked to try this in the Vagrant version before doing it in production :slight_smile:

I need a bit more help though. If I ssh into vagrant and open the console with rails c. What then?

That’s a c for Console
It will let you run Ruby from the command line.

Similarly you can rails db and run DataBase queries from the command line.

*Hint, please do yourself a favor and save backups or be prepared and willing to start from scratch if things turn sour.


In other words: Footgun, batteries not included


I’ll be working in my local Vagrant instance using a backup from the production docker. Starting from scratch is not an option at this point. We have migrated our Ning forum to Discourse and it’s now live and being used. There was, unfortunately, no indication in the embedding documentation available about any of these issues.

I’m still not sure what I’m doing. I tried this:

[vagrant@precise32:/vagrant (master)]$ rails db
psql (9.4.1)
Type "help" for help.

discourse_development=> DELETE FROM topic_embeds
discourse_development-> \q

But it doesn’t seem to be working. Or I don’t understand how to test this.

I visited the local version of the website but the “Continue the Discussion” link there tries to take me to old (deleted) topic at http://localhost:4000/t/profiles-events/18.

FWIW, I have as an allowed host.


I think you need to end your statement with ;, otherwise it thinks you are trying to write a multi-line query.


DELETE FROM topic_embeds;

Just landed here after I deleted a topic I’d created under Discourse 2 and low and behold this sage advice still works to restore deleted topics. That’s awesome! :smile:

1 Like

How can we restore topic discourse?
I deleted content of first topic, so it’s lost, now i wanna restore them. How do i?
Do Discourse have recycle bin topic?
Thank you!

Search, find the deleted topic and click the Un-delete button



Thanks-you very much! Works perfectly :kissing_heart:


How can i search or list all topic Make unlisted?

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