models: Drop unique index on user/message/emoji_name.

c7d0192755 added the unique constraint on
`user_profile_id,message_id,reaction_type,emoji_code`, but left the
existing constraint on `user_profile_id,message_id,emoji_name`.  As
explained in the comment added in 3cd543ee98, `emoji_name` cannot be
trusted to be unique, as it is possible to have an Unicode emoji
reaction and a custom emoji with the same name on a message.

Remove the overly-constraining unique index, now that c7d0192755 has
provided the correct one.
This commit is contained in:
Alex Vandiver 2023-02-25 01:29:12 +00:00 committed by Tim Abbott
parent b0d9b319e3
commit 52b8a84219
2 changed files with 21 additions and 4 deletions

View File

@ -0,0 +1,20 @@
# Generated by Django 4.1.6 on 2023-02-25 01:22
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("zerver", "0430_fix_audit_log_objects_for_group_based_stream_settings"),
]
operations = [
migrations.AlterUniqueTogether(
name="archivedreaction",
unique_together={("user_profile", "message", "reaction_type", "emoji_code")},
),
migrations.AlterUniqueTogether(
name="reaction",
unique_together={("user_profile", "message", "reaction_type", "emoji_code")},
),
]

View File

@ -3169,10 +3169,7 @@ class AbstractEmoji(models.Model):
class AbstractReaction(AbstractEmoji): class AbstractReaction(AbstractEmoji):
class Meta: class Meta:
abstract = True abstract = True
unique_together = ( unique_together = ("user_profile", "message", "reaction_type", "emoji_code")
("user_profile", "message", "emoji_name"),
("user_profile", "message", "reaction_type", "emoji_code"),
)
class Reaction(AbstractReaction): class Reaction(AbstractReaction):