diff mbox series

models: Add covering index for Patch.hash

Message ID 20240124110946.481812-1-stephen@that.guru
State New
Headers show
Series models: Add covering index for Patch.hash | expand

Commit Message

Stephen Finucane Jan. 24, 2024, 11:09 a.m. UTC
Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #579
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
---
 .../migrations/0047_add_database_indexes.py    | 18 ++++++++++++++++++
 patchwork/models.py                            |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 patchwork/migrations/0047_add_database_indexes.py
diff mbox series

Patch

diff --git a/patchwork/migrations/0047_add_database_indexes.py b/patchwork/migrations/0047_add_database_indexes.py
new file mode 100644
index 00000000..42c11997
--- /dev/null
+++ b/patchwork/migrations/0047_add_database_indexes.py
@@ -0,0 +1,18 @@ 
+import patchwork.fields
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+    dependencies = [
+        ('patchwork', '0046_patch_comment_events'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='patch',
+            name='hash',
+            field=patchwork.fields.HashField(
+                blank=True, db_index=True, max_length=40, null=True
+            ),
+        ),
+    ]
diff --git a/patchwork/models.py b/patchwork/models.py
index 9a619bc5..38b52b05 100644
--- a/patchwork/models.py
+++ b/patchwork/models.py
@@ -501,7 +501,7 @@  class Patch(SubmissionMixin):
     )
     state = models.ForeignKey(State, null=True, on_delete=models.CASCADE)
     archived = models.BooleanField(default=False)
-    hash = HashField(null=True, blank=True)
+    hash = HashField(null=True, blank=True, db_index=True)
 
     # series metadata