HomePhabricator
Diffusion Comm 5124cc0e9c93

[keyserver] Fix existing memberships.last_message in migration

Description

[keyserver] Fix existing memberships.last_message in migration

Summary:
ENG-4101
Depends on D9598

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.

Test Plan: Run the migration, check if the last_message was correctly updated.

Reviewers: tomek, inka, ashoat

Reviewed By: ashoat

Subscribers: ashoat, tomek, wyilio

Differential Revision: https://phab.comm.dev/D9605