Files
zulip/zerver/migrations/0429_user_topic_case_insensitive_unique_toghether.py
Tim Abbott afecb2eca6 migrations: Add missing elidable tags on RunPython/RunSQL steps.
This helps the squashmigrations tool know that it can squash these.
2024-08-23 17:15:35 -07:00

34 lines
1.1 KiB
Python

# Generated by Django 4.1.6 on 2023-02-11 05:16
import django.db.models.functions.text
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("zerver", "0428_remove_realm_email_address_visibility"),
]
operations = [
migrations.AlterUniqueTogether(
name="usertopic",
unique_together=set(),
),
# Before adding the constraint, remove any pre-existing duplicates from the table
migrations.RunSQL(
"""
DELETE FROM zerver_usertopic WHERE id NOT IN (SELECT max(id) FROM zerver_usertopic GROUP BY (user_profile_id, stream_id, upper(topic_name::text)));
""",
elidable=True,
),
migrations.AddConstraint(
model_name="usertopic",
constraint=models.UniqueConstraint(
models.F("user_profile"),
models.F("stream"),
django.db.models.functions.text.Lower("topic_name"),
name="usertopic_case_insensitive_topic_uniq",
),
),
]