-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migration to cleanup dead invites
Fixes #350.
- Loading branch information
David Robertson
committed
Oct 19, 2023
1 parent
867cf68
commit b4f30f5
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- +goose Up | ||
-- +goose StatementBegin | ||
WITH | ||
dead_invites(user_id, room_id) AS ( | ||
SELECT syncv3_invites.user_id, syncv3_invites.room_id | ||
FROM syncv3_invites | ||
JOIN syncv3_rooms USING (room_id) | ||
JOIN syncv3_snapshots ON (syncv3_snapshots.snapshot_id = syncv3_rooms.current_snapshot_id) | ||
JOIN syncv3_events ON ( | ||
event_nid = ANY (membership_events) | ||
AND state_key = syncv3_invites.user_id | ||
AND NOT (membership = 'invite' OR membership = '_invite') | ||
) | ||
) | ||
DELETE FROM syncv3_invites | ||
WHERE (user_id, room_id) IN (SELECT * FROM dead_invites); | ||
-- +goose StatementEnd | ||
|
||
-- +goose Down | ||
-- +goose StatementBegin | ||
-- no-op | ||
-- +goose StatementEnd |