Hi all,
We’re using Nakama’s persistent chat messages, which are stored in the database. To keep the database clean and prevent unlimited growth, we’re looking for best practices to automatically delete old chat data.
I’m aware of the Nakama Console option under Chat Messages/Delete Messages:
Are you sure you want to delete all messages before retain days?
Choose how many days to retain:n
However, I’m not sure whether this is the recommended approach for production use, or if it’s mainly intended as a manual / maintenance tool.
For our use case, we’re considering the following policies:
-
Direct messages
Automatically delete messages afternretain days. -
In-game / match chat
Delete messages when the match ends or when the last user leaves the room. -
Group chat
Automatically delete messages afternretain days.
Questions:
-
Is using the Console’s “delete before retain days” feature the intended way to handle this?
-
Is it better practice to implement a custom cleanup mechanism (e.g. a cron job using server runtime code or direct DB cleanup)?
-
Are there recommended patterns or pitfalls to be aware of when deleting chat messages (performance, indexes, message history, etc.)?
-
Is there any built-in automation or retention configuration per chat type (DM / room / group), or is everything global?
Any guidance or real-world experience would be greatly appreciated.
Thanks!