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:
parent
ef2830d36a
commit
4f322456e9
1 changed files with 1 additions and 1 deletions
|
|
@ -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():
|
||||
|
|
|
|||
Loading…
Reference in a new issue