Replace unique_together with UniqueConstraint on OrderLine
This commit is contained in:
2 files changed
+23
-1
No files matched your search
@@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 5.2.18 on 2026-10-22 23:51
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("bbs", "0003_alter_order_order_sum"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterUniqueTogether(
|
||||||
|
name="orderline",
|
||||||
|
unique_together=set(),
|
||||||
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name="orderline",
|
||||||
|
constraint=models.UniqueConstraint(fields=("order", "product"), name="unique_order_product"),
|
||||||
|
),
|
||||||
|
]
|
||||||
+3
-1
@@ -171,7 +171,9 @@ class OrderLine(models.Model):
|
|||||||
return f"{self.amount} {self.product} ({self.unit_price} kr per)"
|
return f"{self.amount} {self.product} ({self.unit_price} kr per)"
|
||||||
|
|
||||||
class Meta: # noqa: DJ012
|
class Meta: # noqa: DJ012
|
||||||
unique_together = ("order", "product")
|
constraints = [
|
||||||
|
models.UniqueConstraint(fields=["order", "product"], name="unique_order_product"),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class Transaction(models.Model):
|
class Transaction(models.Model):
|
||||||
|
|||||||
Reference in new issue
Block a user