Skip to content

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

Added Index for 'Created' field of the Order Model (#13682)

ritanjandawn66856c8975a7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ea4b0beb1e..8305477022 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -201,6 +201,7 @@ Shipping methods can be removed by the user after it has been assigned to a chec
- Fix seo field to accept null value - #13512 by @ssuraliya
- Add missing descriptions to payment module - #13546 by @devilsautumn
- Fix `NOTIFY_USER` allow to create webhook with only one event - #13584 by @Air-t
+- Add Index for 'Created' field of the Order Model - #13682 by @ritanjandawn
# 3.14.0
diff --git a/saleor/order/migrations/0174_order_idx_order_created_at.py b/saleor/order/migrations/0174_order_idx_order_created_at.py
new file mode 100644
index 0000000000..2dd6c561b3
--- /dev/null
+++ b/saleor/order/migrations/0174_order_idx_order_created_at.py
@@ -0,0 +1,19 @@
+# Generated by Django 3.2.20 on 2023-08-31 17:45
+
+from django.db import migrations, models
+from django.contrib.postgres.operations import AddIndexConcurrently
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("order", "0173_auto_20230816_1245"),
+ ]
+
+ atomic = False
+
+ operations = [
+ AddIndexConcurrently(
+ model_name="order",
+ index=models.Index(fields=["created_at"], name="idx_order_created_at"),
+ ),
+ ]
diff --git a/saleor/order/models.py b/saleor/order/models.py
index ee596af066..c0f384d2ba 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -347,6 +347,7 @@ class Order(ModelWithMetadata, ModelWithExternalReference):
fields=["user_email"],
opclasses=["gin_trgm_ops"],
),
+ models.Index(fields=["created_at"], name="idx_order_created_at"),
]
def is_fully_paid(self):