Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add data migration for attribute with many values

fowczarek17d6d8cf1851
diff --git a/saleor/product/migrations/0108_auto_20191003_0422.py b/saleor/product/migrations/0108_auto_20191003_0422.py
index 32e0575875..ca96d90422 100644
--- a/saleor/product/migrations/0108_auto_20191003_0422.py
+++ b/saleor/product/migrations/0108_auto_20191003_0422.py
@@ -36,7 +36,7 @@ def remove_duplicated_attribute_values(apps, schema_editor):
list(value_to_be_removed.assignedproductattribute_set.all())
)
for invalid_assigned_attribute in invalid_assigned_attributes:
- invalid_assigned_attribute.values.clear()
+ invalid_assigned_attribute.values.remove(value_to_be_removed)
invalid_assigned_attribute.values.add(final_value)
ids_to_be_removed = values_to_be_removed.values_list("id", flat=True)
AttributeValue.objects.filter(id__in=ids_to_be_removed).delete()