: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(signals): drop the redundant team_id index on scout configs (#96205)
posthog[bot]10bdefed8d91
diff --git a/products/signals/backend/migrations/0117_drop_signalscoutconfig_team_id_fk_idx.py b/products/signals/backend/migrations/0117_drop_signalscoutconfig_team_id_fk_idx.pynew file mode 100644index 000000000000..fbe6e911472a--- /dev/null+++ b/products/signals/backend/migrations/0117_drop_signalscoutconfig_team_id_fk_idx.py@@ -0,0 +1,40 @@+import django.db.models.deletion+from django.db import migrations, models++from posthog.migration_helpers import DropIndexConcurrently+++class Migration(migrations.Migration):+ # Concurrent index drops cannot run inside a transaction.+ atomic = False++ dependencies = [+ ("signals", "0116_signalscoutconfig_write_scopes"),+ ]++ operations = [+ # Django's automatic ForeignKey index. `unique_scout_config_per_team_skill` on+ # (team, skill_name) and `scout_config_source_idx` on (team, source_product,+ # source_id) both lead with team_id, so this index serves no read.+ migrations.SeparateDatabaseAndState(+ state_operations=[+ migrations.AlterField(+ model_name="signalscoutconfig",+ name="team",+ field=models.ForeignKey(+ db_index=False,+ on_delete=django.db.models.deletion.CASCADE,+ related_name="signal_scout_configs",+ to="posthog.team",+ ),+ ),+ ],+ database_operations=[+ DropIndexConcurrently(+ index_name="signals_signalscoutconfig_team_id_f5c45cf6",+ table_name="signals_signalscoutconfig",+ columns="(team_id)",+ ),+ ],+ ),+ ]diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txtindex 70c1393c5846..87c58640a65f 100644--- a/products/signals/backend/migrations/max_migration.txt+++ b/products/signals/backend/migrations/max_migration.txt@@ -1 +1 @@-0116_signalscoutconfig_write_scopes+0117_drop_signalscoutconfig_team_id_fk_idxdiff --git a/products/signals/backend/models.py b/products/signals/backend/models.pyindex aef38311a899..f5b155b76b03 100644--- a/products/signals/backend/models.py+++ b/products/signals/backend/models.py@@ -1495,10 +1495,13 @@ class SignalScoutConfig(ModelActivityMixin, TeamScopedRootMixin, UUIDModel):# doesn't bake it in (most callers don't need it).all_teams = models.Manager() # noqa: DJ012+ # No single-column index: the constraint and index below both lead with team_id,+ # so a team-scoped read is already served.team = models.ForeignKey("posthog.Team",on_delete=models.CASCADE,related_name="signal_scout_configs",+ db_index=False,)# The LLMSkill this row references (controlling only its scheduling /# enablement, not the skill itself). The coordinator auto-creates a