How can I delete or undelete topics?

I used the embedded feature to tie together a blog with my forum. While testing I deleted all those posts. Now that I’m trying to re-create the integration I realised that deleting posts just don’t actually delete them, it just hides them. So, now the integration is broken because users don’t have access to them.

How can I:

  • Really delete the topics so that the embedding can re-create them?
  • OR find a list of all the “deleted” posts so that I can undelete them?

(C.f. Embedding Discourse Comments via Javascript)


If all the posts you deleted was created by you, then under your profile you can see what posts you deleted and then you can undo the delete


By site setting the posts you deleted are only hidden (to all except admins) for 24 h.

In this period you can undelete all of them. After 24 h they are deleted forever.

1 Like

@Trash: Thanks, but this setting doesn’t apply to topics, only to posts. In any case, I don’t think it even really deletes them from the database, which is what I’m asking for.

@zee: Where is this? I looked under but I can’t find anything. (Though, again, I’m talking about topics not posts.)

This site setting is unrelated – it only applies to posts deleted by the author, which will stick around as (deleted by author, will be removed in 24 hours unless flagged) for the specified time.

Profiles with deleted topics once showed a red “notification” to staff members, but it seems to be gone. Maybe this was dropped when the Activity page was restructured (by @sam if I recall correctly).

You can definitely use the Data Explorer to find deleted topics, though.

And here’s how:

Run this query:

FROM topics
WHERE deleted_at is not NULL
AND archetype = 'regular'

Look through the list to find the topic, and memorize the ID.
Then, visit /t/<id> in your Discourse install to view the topic. From there, you can easily restore the topic.


As admin the posts you have deleted should be listed here:{your-username-here}/deleted-posts

This is linked from the top of your profile page, clicking the button will show something like this in the top left:

Click “deleted posts” to see the posts you have deleted.


There is also the querystring (also works with category/latest page)



@DeanMarkTaylor: thanks for pointing out this helpful, though well-hidden, feature. But it only lists posts, not topics.

The solutions that @fefrei and @cpradio suggested work fine, though the latter is simpler to use.

Unfortunately I can’t undelete topics at all. I have two admin accounts, the one that was used during embedding to create the topics in the first place ( adminbot) and my personal account (alex). I tried undeleting the topics with both accounts and neither works. The topics remain deleted.

Is there a way to really delete the topics?

This is risky, and I’d advise you wait until a Discourse Team member can provide better feedback, but something like this should work from the Rails console, so long as you know the topic ids you want to delete.


@alehandrof Sorry wasn’t online last few days, What I was talking about @DeanMarkTaylor posted a screen shot

1 Like

I’m having trouble following as there at least 2 if not 3 issues being discussed.

In regards to Topics, in the context of deleting / undeleting topics Discourse considers the OP as the Topic. That is, the topic is the first post.

In other words, if the first post is deleted (the trash can icon), the topic is deleted. Regardless of how many replies it might have.

Conversely, if the first post has been deleted, the “counter-clockwise circular arrow” icon can be used to undelete the OP, thus in effect undeleting the topic.

As far as “really” deleting a topic, as in removing all trace of it from the database. I don’t know, but I would strongly suggest this not be attempted.

There is a lot of cross-indexing of tables and unless there is some type of DELETE CASCADE that I haven’t seen yet things could break in the most horrible way imaginable.


@Mittineague: I’ve done a sloppy job of describing what the issue is. Let me try again. I’m usually better on the 2nd try.

I want to start embedding topics on a live site. Unfortunately, I already set up embedding in the past. While I was testing things, I deleted the topics that were thus created.


  • I am not able to undelete the embedded topics even with the account that created them. I undeleted two of them, but the rest refuse to be undeleted. No idea why.
  • I am not able to totally remove the embedded topics from the database.

Either would work (and I would prefer the second), but neither does. So I’m stuck. Ideas?

Edit: revised for clarity

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.)