DEV: Ensure unique notification level per tag user (#28638)

TagUser.rb is used to set user notification levels for a tag, we don't have a unique index on the notification level itself. This means that there might be some weird case where a user may have multiple of the same notification level on a tag.

This PR adds a migration which de-duplicates this based on defaults, where we keep the earliest record in the event there is multiple notification level per-user-per-tag.
This commit is contained in:
Natalie Tay
2024-09-03 15:43:02 +08:00
committed by GitHub
parent 74c9b5c11c
commit cc873977ec
4 changed files with 45 additions and 2 deletions

View File

@@ -259,6 +259,7 @@ end
#
# Indexes
#
# idx_tag_users_ix1 (user_id,tag_id,notification_level) UNIQUE
# idx_tag_users_ix2 (tag_id,user_id,notification_level) UNIQUE
# index_tag_users_on_tag_id_and_user_id_and_notification_level (tag_id,user_id,notification_level)
# index_tag_users_on_user_id_and_tag_id (user_id,tag_id) UNIQUE
# index_tag_users_on_user_id_and_tag_id_and_notification_level (user_id,tag_id,notification_level)
#