In the previous diff we start correctly setting the memmberships.last_message value for new users. But we still need to update the existing users. This diff adds a new migration that migrates the genesis rows for all users. The query is based on the query from the previous diff but:
- it doesn't update the last_read_message (we don't need to change it, as it should be correct)
- it has additional constraints on the main query and the subqueries .thread = 1, so it only searches genesis messages and makes the query faster
Because of these changes and because this is just a migration I don't think it's worth abstracing this query from thread-permission-updaters so I just copied the necessary parts.