Skip to content

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

add index on transaction token (#16476)

Krzysztof Waliczek1075496c64dd
diff --git a/saleor/payment/migrations/0057_transaction_token_idx.py b/saleor/payment/migrations/0057_transaction_token_idx.py
new file mode 100644
index 0000000000..46c68c597d
--- /dev/null
+++ b/saleor/payment/migrations/0057_transaction_token_idx.py
@@ -0,0 +1,23 @@
+# Generated by Django 3.2.25 on 2024-07-31 10:07
+
+from django.contrib.postgres.indexes import GinIndex
+from django.contrib.postgres.operations import AddIndexConcurrently
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ atomic = False
+
+ dependencies = [
+ ("payment", "0056_fix_invalid_atobarai_payments"),
+ ]
+
+ operations = [
+ AddIndexConcurrently(
+ model_name="transaction",
+ index=GinIndex(
+ fields=["token"],
+ name="token_idx",
+ ),
+ ),
+ ]
diff --git a/saleor/payment/migrations/0058_merge_20240802_1119.py b/saleor/payment/migrations/0058_merge_20240802_1119.py
new file mode 100644
index 0000000000..e17b047b3d
--- /dev/null
+++ b/saleor/payment/migrations/0058_merge_20240802_1119.py
@@ -0,0 +1,12 @@
+# Generated by Django 3.2.25 on 2024-08-02 11:19
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("payment", "0057_merge_20240514_0825"),
+ ("payment", "0057_transaction_token_idx"),
+ ]
+
+ operations = []
diff --git a/saleor/payment/migrations/0059_merge_20240802_1125.py b/saleor/payment/migrations/0059_merge_20240802_1125.py
new file mode 100644
index 0000000000..b1ad41a5ef
--- /dev/null
+++ b/saleor/payment/migrations/0059_merge_20240802_1125.py
@@ -0,0 +1,12 @@
+# Generated by Django 3.2.25 on 2024-08-02 11:25
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("payment", "0058_merge_20240514_1004"),
+ ("payment", "0058_merge_20240802_1119"),
+ ]
+
+ operations = []
diff --git a/saleor/payment/models.py b/saleor/payment/models.py
index cb9f377884..b4f26ca32d 100644
--- a/saleor/payment/models.py
+++ b/saleor/payment/models.py
@@ -447,6 +447,12 @@ class Transaction(models.Model):
class Meta:
ordering = ("pk",)
+ indexes = [
+ GinIndex(
+ name="token_idx",
+ fields=["token"],
+ ),
+ ]
def __repr__(self):
return (