:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(review_hog): drop duplicate report indexes on artefacts (#115918)
Julian Bez7e9edb656927
diff --git a/products/review_hog/backend/migrations/0035_drop_duplicate_artefact_report_indexes.py b/products/review_hog/backend/migrations/0035_drop_duplicate_artefact_report_indexes.pynew file mode 100644index 000000000000..1c4e178f9fff--- /dev/null+++ b/products/review_hog/backend/migrations/0035_drop_duplicate_artefact_report_indexes.py@@ -0,0 +1,16 @@+from django.db import migrations++from posthog.migration_helpers import DropFieldIndexesConcurrently, SafeRemoveIndexConcurrently+++class Migration(migrations.Migration):+ atomic = False++ dependencies = [+ ("review_hog", "0034_review_repositories"),+ ]++ operations = [+ DropFieldIndexesConcurrently(model_name="reviewreportartefact", name="report"),+ SafeRemoveIndexConcurrently(model_name="reviewreportartefact", name="reviewhog_art_report_idx"),+ ]diff --git a/products/review_hog/backend/migrations/max_migration.txt b/products/review_hog/backend/migrations/max_migration.txtindex 401f454ad7b2..ef744affca41 100644--- a/products/review_hog/backend/migrations/max_migration.txt+++ b/products/review_hog/backend/migrations/max_migration.txt@@ -1 +1 @@-0034_review_repositories+0035_drop_duplicate_artefact_report_indexesdiff --git a/products/review_hog/backend/models.py b/products/review_hog/backend/models.pyindex 625a2f691e05..5fc7a973091f 100644--- a/products/review_hog/backend/models.py+++ b/products/review_hog/backend/models.py@@ -223,7 +223,9 @@ class ReviewReportArtefact(UUIDModel, TeamScopedRootMixin):# db_constraint=False keeps the migration lock-free on hot posthog_team.team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+", db_constraint=False)- report = models.ForeignKey(ReviewReport, on_delete=models.CASCADE, related_name="artefacts")+ # db_index=False: the (report, type) composite indexes below lead with report_id, so they serve+ # lookups and cascade deletes. A separate single-column index would be redundant.+ report = models.ForeignKey(ReviewReport, on_delete=models.CASCADE, related_name="artefacts", db_index=False)type = models.CharField(max_length=100, choices=review_report_artefact_type_choices)content = models.TextField()# Turn scope, denormalized from content.head_sha so resume loaders can filter in SQL instead of@@ -242,7 +244,6 @@ class ReviewReportArtefact(UUIDModel, TeamScopedRootMixin):class Meta:indexes = [- models.Index(fields=["report"], name="reviewhog_art_report_idx"),models.Index(fields=["report", "type"], name="reviewhog_art_rpt_type_idx"),# Latest-wins seeks: WHERE report=? AND type=? ORDER BY created_at DESC.models.Index(fields=["report", "type", "-created_at"], name="reviewhog_art_rpt_type_ct_idx"),