From 1fed75584e181a32f42bf8beb5ed39ce67016e7b Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Sun, 19 Oct 2025 00:16:57 +0300 Subject: [PATCH] Features: 1) Add migration to enforce unique constraint on Attribute model for fields `name`, `group`, and `value_type`; Fixes: 1) Remove redundant traceback logging in `core/vendors/__init__.py`; Extra: 1) Update Attribute model's `unique_together` to include `value_type`. --- .../0047_alter_attribute_unique_together.py | 16 ++++++++++++++++ core/models.py | 1 + core/vendors/__init__.py | 1 - 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 core/migrations/0047_alter_attribute_unique_together.py diff --git a/core/migrations/0047_alter_attribute_unique_together.py b/core/migrations/0047_alter_attribute_unique_together.py new file mode 100644 index 00000000..18cdadef --- /dev/null +++ b/core/migrations/0047_alter_attribute_unique_together.py @@ -0,0 +1,16 @@ +# Generated by Django 5.2 on 2025-10-18 21:16 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("core", "0046_alter_attribute_name_alter_attribute_name_ar_ar_and_more"), + ] + + operations = [ + migrations.AlterUniqueTogether( + name="attribute", + unique_together={("name", "group", "value_type")}, + ), + ] diff --git a/core/models.py b/core/models.py index 63e00571..9595beee 100644 --- a/core/models.py +++ b/core/models.py @@ -667,6 +667,7 @@ class Attribute(ExportModelOperationsMixin("attribute"), NiceModel): # type: ig unique_together = ( "name", "group", + "value_type", ) verbose_name = _("attribute") verbose_name_plural = _("attributes") diff --git a/core/vendors/__init__.py b/core/vendors/__init__.py index 8bc2183c..31e8f957 100644 --- a/core/vendors/__init__.py +++ b/core/vendors/__init__.py @@ -451,7 +451,6 @@ class AbstractVendor: attribute.save() except IntegrityError: async_logger.warning(f"IntegrityError while processing attribute {key!r}...") - async_logger.warning(traceback.format_exc()) return attribute.save()