Fix duplicate detection by using UUID in migration script

The migration script now counts duplicates based on the "uuid" field instead of "id". This ensures more accurate identification of duplicate "human_readable_id" entries.
This commit is contained in:
Egor Pavlovich Gorbunov 2025-05-06 17:16:52 +03:00
parent 146bbc3539
commit ef2830d36a

View file

@ -8,7 +8,7 @@ def fix_duplicates(apps, schema_editor):
Order = apps.get_model("core", "Order")
duplicates = (
Order.objects.values("human_readable_id")
.annotate(count=Count("id"))
.annotate(count=Count("uuid"))
.filter(count__gt=1)
)
for duplicate in duplicates: