From 5cfe7eca6f3c177cc436812e45dfb03288b5fbc2 Mon Sep 17 00:00:00 2001 From: Bart Schuurmans Date: Wed, 3 Apr 2024 21:06:24 +0200 Subject: [PATCH] Add index for finding all statuses in a thread --- ...0_status_bookwyrm_st_thread__cf064f_idx.py | 19 +++++++++++++++++++ bookwyrm/models/status.py | 1 + 2 files changed, 20 insertions(+) create mode 100644 bookwyrm/migrations/0200_status_bookwyrm_st_thread__cf064f_idx.py diff --git a/bookwyrm/migrations/0200_status_bookwyrm_st_thread__cf064f_idx.py b/bookwyrm/migrations/0200_status_bookwyrm_st_thread__cf064f_idx.py new file mode 100644 index 000000000..daca654c7 --- /dev/null +++ b/bookwyrm/migrations/0200_status_bookwyrm_st_thread__cf064f_idx.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.25 on 2024-04-03 19:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0199_status_bookwyrm_st_remote__06aeba_idx"), + ] + + operations = [ + migrations.AddIndex( + model_name="status", + index=models.Index( + fields=["thread_id"], name="bookwyrm_st_thread__cf064f_idx" + ), + ), + ] diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index a9c678cb5..546a8d6c8 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -82,6 +82,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): ordering = ("-published_date",) indexes = [ models.Index(fields=["remote_id"]), + models.Index(fields=["thread_id"]), ] def save(self, *args, **kwargs):