# Can you bulk rebake chat messages?

**URL:** https://meta.discourse.org/t/can-you-bulk-rebake-chat-messages/294412
**Category:** Support
**Tags:** chat
**Created:** [February 6, 2024, 8:45pm UTC](https://meta.discourse.org/t/can-you-bulk-rebake-chat-messages/294412 "2024-02-06T20:45:29Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [February 6, 2024, 8:45pm UTC](https://meta.discourse.org/t/can-you-bulk-rebake-chat-messages/294412/1 "2024-02-06T20:45:29Z")

</div>

I assume that you can (probably similarly to posts), just not sure how. We had an admin run a database edit on all chat messages by mistake trying to edit some in one channel, and now we need to rebake all affected chat messages (Which, unfortunately, seems to be _all_ chat messages in _all_ channels, including DMs)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 6, 2024, 9:09pm UTC](https://meta.discourse.org/t/can-you-bulk-rebake-chat-messages/294412/2 "2024-02-06T21:09:39Z")

</div>

There is a

```plaintext
rake chat_messages:rebake_uncooked_chat_messages

```

So I guess you’d need to _do something_ to un-mark them as cooked.

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [February 6, 2024, 9:12pm UTC](https://meta.discourse.org/t/can-you-bulk-rebake-chat-messages/294412/3 "2024-02-06T21:12:41Z")

</div>

Is there a way we could mark all of them as uncooked? (~99% of our chat messages need rebaked, so just hitting all of them is fine)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 6, 2024, 9:16pm UTC](https://meta.discourse.org/t/can-you-bulk-rebake-chat-messages/294412/4 "2024-02-06T21:16:09Z")

</div>

```plaintext
Chat::Message.update_all(cooked_version: nil)

```

I think that will do it, but I’m not making any promises that it won’t ruin your life.

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [February 6, 2024, 11:23pm UTC](https://meta.discourse.org/t/can-you-bulk-rebake-chat-messages/294412/5 "2024-02-06T23:23:51Z")

</div>

> [@pfaffman](#):
>
> I’m not making any promises that it won’t ruin your life.

Heh, can’t be that much worse than it already is.

---

<div class="post-metadata">

### Author: ![hello-smile6](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hello-smile6/32/304628_2.png) [@hello-smile6](https://meta.discourse.org/u/hello-smile6)
#### Post date: [February 6, 2024, 11:44pm UTC](https://meta.discourse.org/t/can-you-bulk-rebake-chat-messages/294412/6 "2024-02-06T23:44:05Z")

</div>

Make sure to create a backup first!

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [April 16, 2024, 11:07am UTC](https://meta.discourse.org/t/can-you-bulk-rebake-chat-messages/294412/7 "2024-04-16T11:07:17Z")

</div>

Out of curiosity, did that do the trick?

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [April 16, 2024, 1:59pm UTC](https://meta.discourse.org/t/can-you-bulk-rebake-chat-messages/294412/8 "2024-04-16T13:59:48Z")

</div>

IIRC, I think what we ended up doing was:

1. Run:

> [@pfaffman](#):
>
> ```plaintext
> Chat::Message.update_all(cooked_version: nil)
> 
> ```

1. Restore all messages we could from an older backup
2. Rebake the rest
