Can you bulk rebake chat messages?

AI-generated summary

The discussion is about rebaking chat messages in bulk. After an admin accidentally edited all chat messages in the database, Firepup650 sought help to rebake all affected messages. pfaffman suggested running the command rake chat_messages:rebake_uncooked_chat_messages but noted that the messages would need to be marked as uncooked first. pfaffman provided the command Chat::Message.update_all(cooked_version: nil) to do so, warning that it could have unintended consequences. hello-smile6 advised creating a backup before proceeding. In the end, Firepup650 ran the suggested command, restored messages from an older backup, and rebaked the rest.

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)

There is a

rake chat_messages:rebake_uncooked_chat_messages

So I guess you’d need to do something to un-mark them as cooked.

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)

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.

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

Make sure to create a backup first!

Out of curiosity, did that do the trick?

IIRC, I think what we ended up doing was:

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