Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix clearorders command not to raise IntegrityError (#16787)
Tomasz Szymańskiaf16d48598d1
diff --git a/saleor/core/management/commands/clearorders.py b/saleor/core/management/commands/clearorders.pyindex 33f5aa2cea..6aeaa97558 100644--- a/saleor/core/management/commands/clearorders.py+++ b/saleor/core/management/commands/clearorders.py@@ -9,7 +9,7 @@ from django.core.management.base import BaseCommandfrom ....account.models import Address, CustomerEvent, CustomerNote, Userfrom ....checkout.models import Checkout, CheckoutLine, CheckoutMetadata-from ....discount.models import OrderDiscount+from ....discount.models import OrderDiscount, OrderLineDiscountfrom ....giftcard.models import GiftCard, GiftCardEvent, GiftCardTagfrom ....invoice.models import Invoice, InvoiceEventfrom ....order.models import Fulfillment, FulfillmentLine, Order, OrderEvent, OrderLine@@ -109,6 +109,9 @@ class Command(BaseCommand):self.stdout.write("Removed gift cards")def delete_orders(self):+ line_discounts = OrderLineDiscount.objects.all()+ line_discounts._raw_delete(line_discounts.db) # type: ignore[attr-defined] # raw access # noqa: E501+discounts = OrderDiscount.objects.all()discounts._raw_delete(discounts.db) # type: ignore[attr-defined] # raw access # noqa: E501