2020-07-15 17:25:47 +02:00
|
|
|
from django.db import migrations
|
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
2021-02-12 08:20:45 +01:00
|
|
|
("zerver", "0294_remove_userprofile_pointer"),
|
2020-07-15 17:25:47 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
# Zulip has always had case-insensitive matching for email
|
|
|
|
# addresses on UserProfile objects. But Django's
|
|
|
|
# unique_together feature only supports case-sensitive
|
|
|
|
# indexes. So we reply the old unique_together index with a
|
|
|
|
# new case-insensitive index.
|
|
|
|
#
|
|
|
|
# Further, when we created the delivery_email field, we
|
|
|
|
# neglected to create an unique index on (realm_id,
|
|
|
|
# delivery_email), which meant race conditions or logic bugs
|
|
|
|
# could allow duplicate user accounts being created in
|
|
|
|
# organizations with EMAIL_ADDRESS_VISIBILITY_ADMINS. We
|
|
|
|
# correct this by adding the appropriate unique index there as
|
|
|
|
# well.
|
2021-02-12 08:19:30 +01:00
|
|
|
migrations.RunSQL(
|
|
|
|
"""
|
2020-07-15 17:25:47 +02:00
|
|
|
CREATE UNIQUE INDEX zerver_userprofile_realm_id_email_uniq ON zerver_userprofile (realm_id, upper(email::text));
|
|
|
|
CREATE UNIQUE INDEX zerver_userprofile_realm_id_delivery_email_uniq ON zerver_userprofile (realm_id, upper(delivery_email::text));
|
2021-02-12 08:19:30 +01:00
|
|
|
"""
|
|
|
|
),
|
2020-07-15 17:25:47 +02:00
|
|
|
migrations.AlterUniqueTogether(
|
2021-02-12 08:20:45 +01:00
|
|
|
name="userprofile",
|
2020-07-15 17:25:47 +02:00
|
|
|
unique_together=set(),
|
|
|
|
),
|
|
|
|
]
|