Fix order sorting by changing ordering field to UUID

Previously, orders with duplicate `human_readable_id` were sorted by `id`, which could lead to inconsistencies. Updated the code to sort by `uuid` to ensure a more reliable and unique ordering. This prevents potential issues when resolving duplicate entries.
This commit is contained in:
Egor Pavlovich Gorbunov 2025-05-06 17:18:57 +03:00
parent ef2830d36a
commit 4f322456e9

View file

@ -13,7 +13,7 @@ def fix_duplicates(apps, schema_editor):
)
for duplicate in duplicates:
h_id = duplicate["human_readable_id"]
orders = Order.objects.filter(human_readable_id=h_id).order_by("id")
orders = Order.objects.filter(human_readable_id=h_id).order_by("uuid")
for order in orders[1:]:
new_id = order.human_readable_id
while Order.objects.filter(human_readable_id=new_id).exists():