# 개인 메시지를 수천 개 삭제하는 방법?

**URL:** https://meta.discourse.org/t/how-to-delete-thousands-of-personal-messages/162747
**Category:** Support
**Tags:** personal-messages
**Created:** [9월 2, 2020, 7:12오전 UTC](https://meta.discourse.org/t/how-to-delete-thousands-of-personal-messages/162747 "2020-09-02T07:12:42Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [11월 26, 2021, 7:34오전 UTC](https://meta.discourse.org/t/how-to-delete-thousands-of-personal-messages/162747/7 "2021-11-26T07:34:35Z")

</div>

100% 정확한 답변이 없어서 이 오래된 주제를 다시 꺼내 봅니다.

> [@nildarar](#):
>
> 답장이 100개 이상인 개인 메시지를 데이터베이스에서 완전히 삭제(복구 불가)할 수 있나요?

`rake destroy:private_messages` rake 작업은 모든 개인 메시지를 하드 삭제하지 않으며, 소프트 삭제만 수행합니다. 관리자가 여전히 이를 볼 수 있고 복구도 가능합니다.

Rails 코드 `Topic.where(archetype: 'private_message').where("user_id > 0").destroy_all`은 토픽은 삭제하지만 실제 메시지는 삭제하지 않습니다. 메시지는 여전히 데이터베이스에 남아 있으며, 예를 들어 데이터 탐색기 플러그인을 사용하여 볼 수 있습니다.

다음 코드는 모든 개인 메시지 게시물과 토픽을 영구적으로 삭제합니다:  
**주의: 매우 위험한 작업입니다!**

```plaintext
Post.where(topic_id: Topic.where(archetype: 'private_message').where("user_id > 0")).destroy_all
Topic.where(archetype: 'private_message').where("user_id > 0").destroy_all

```

(답장이 100개 이상인 토픽으로 필터링하려면 두 줄 모두에 `where("posts_count > 100")`을 `Topic.where`에 추가해야 합니다)

---

_[View the full topic](https://meta.discourse.org/t/how-to-delete-thousands-of-personal-messages/162747)._
