Skip to content

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

Add metadata indexes to Payment model

Mateusz Grzybf6d7d6ab88bd
diff --git a/saleor/payment/migrations/0031_auto_20210824_0952.py b/saleor/payment/migrations/0031_auto_20210824_0952.py
new file mode 100644
index 0000000000..45947d4a9a
--- /dev/null
+++ b/saleor/payment/migrations/0031_auto_20210824_0952.py
@@ -0,0 +1,26 @@
+# Generated by Django 3.2.5 on 2021-08-24 09:52
+
+import django.contrib.postgres.indexes
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("payment", "0030_auto_20210823_1702"),
+ ]
+
+ operations = [
+ migrations.AddIndex(
+ model_name="payment",
+ index=django.contrib.postgres.indexes.GinIndex(
+ fields=["private_metadata"], name="payment_p_meta_idx"
+ ),
+ ),
+ migrations.AddIndex(
+ model_name="payment",
+ index=django.contrib.postgres.indexes.GinIndex(
+ fields=["metadata"], name="payment_meta_idx"
+ ),
+ ),
+ ]
diff --git a/saleor/payment/models.py b/saleor/payment/models.py
index bc451aec6a..a30adc7428 100644
--- a/saleor/payment/models.py
+++ b/saleor/payment/models.py
@@ -101,6 +101,7 @@ class Payment(ModelWithMetadata):
),
)
indexes = [
+ *ModelWithMetadata.Meta.indexes,
# Orders filtering by status index
GinIndex(fields=["order_id", "is_active", "charge_status"]),
]