Skip to content

Commit 97ab7ea

Browse files
committed
add ON DELETE CASCADE to FK for rooms
1 parent 756ebad commit 97ab7ea

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

synapse/storage/schema/main/delta/92/04_thread_subscriptions.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ CREATE TABLE thread_subscriptions (
2929

3030
CONSTRAINT thread_subscriptions_fk_rooms
3131
FOREIGN KEY (room_id)
32-
REFERENCES rooms(room_id),
32+
-- When we delete a room, we should already have deleted all the events in that room
33+
-- and so there shouldn't be any subscriptions left in that room.
34+
-- So the `ON DELETE CASCADE` should be optional, but included anyway for good measure.
35+
REFERENCES rooms(room_id) ON DELETE CASCADE,
3336

3437
CONSTRAINT thread_subscriptions_fk_events
3538
FOREIGN KEY (event_id)

0 commit comments

Comments
 (0)