For the hack, we only have one table which stores room_id+key against every message row. This is bonkers for production as there are only a small number of these and we duplicate in every message row.
Refactor to add a room table linked to message table.
Note that in some target systems, message <> room relation could easily be many:many