: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(devex): rewrite reverse-accessor callers to forward queries (#91594)
Julian Bezf06121e75cc7
diff --git a/posthog/caching/warming.py b/posthog/caching/warming.pyindex 139d7b8bce6f..369eaed9d61d 100644--- a/posthog/caching/warming.py+++ b/posthog/caching/warming.py@@ -117,14 +117,16 @@ def insights_to_keep_fresh(team: Team, shared_only: bool = False) -> Generator[tinsight_ids_single.add(insight_id)if insight_ids_single:- single_insights = team.insight_set.filter(+ single_insight_q_filter = Q(+ team=team,insightviewed__last_viewed_at__gte=threshold,pk__in=insight_ids_single,)if shared_only:- single_insights = single_insights.filter(sharingconfiguration__enabled=True)+ single_insight_q_filter &= Q(sharingconfiguration__enabled=True)- for single_insight_id in single_insights.distinct().values_list("id", flat=True):+ single_insight_ids = Insight.objects.filter(single_insight_q_filter).distinct().values_list("id", flat=True)+ for single_insight_id in single_insight_ids:yield single_insight_id, Noneif not dashboard_q_filter:diff --git a/posthog/management/commands/change_plugin_private_access.py b/posthog/management/commands/change_plugin_private_access.pyindex 1300dca1bcb8..a491bdee9dd3 100644--- a/posthog/management/commands/change_plugin_private_access.py+++ b/posthog/management/commands/change_plugin_private_access.py@@ -45,7 +45,7 @@ def run(options):)org = Organization.objects.get(pk=organization_id)- org_current_plugins = org.plugin_set.all()+ org_current_plugins = Plugin.objects.filter(has_private_access=org)logger.info(f"Organization {org.name} currently has explicit access to plugins: [{', '.join([str(plugin.name) for plugin in org_current_plugins])}]")diff --git a/posthog/models/resource_transfer/test/__snapshots__/test_visitor_field_snapshots.ambr b/posthog/models/resource_transfer/test/__snapshots__/test_visitor_field_snapshots.ambrindex 502feb62545a..7c7e9882e7e0 100644--- a/posthog/models/resource_transfer/test/__snapshots__/test_visitor_field_snapshots.ambr+++ b/posthog/models/resource_transfer/test/__snapshots__/test_visitor_field_snapshots.ambr@@ -585,7 +585,6 @@'get_previous_by_created_at','get_restriction_level_display','id',- 'insight_set','is_shared','is_sharing_enabled','items',diff --git a/products/actions/backend/migrations/0002_alter_action_created_by_alter_action_events_and_more.py b/products/actions/backend/migrations/0002_alter_action_created_by_alter_action_events_and_more.pynew file mode 100644index 000000000000..3e18ddd59a45--- /dev/null+++ b/products/actions/backend/migrations/0002_alter_action_created_by_alter_action_events_and_more.py@@ -0,0 +1,52 @@+# Generated by Django 5.2.17 on 2026-09-10 07:52++import django.db.models.deletion+from django.conf import settings+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("actions", "0001_squash_2026_09_07_initial"),+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),+ ]++ operations = [+ migrations.AlterField(+ model_name="action",+ name="created_by",+ field=models.ForeignKey(+ blank=True,+ null=True,+ on_delete=django.db.models.deletion.SET_NULL,+ related_name="+",+ to=settings.AUTH_USER_MODEL,+ ),+ ),+ migrations.AlterField(+ model_name="action",+ name="events",+ field=models.ManyToManyField(blank=True, related_name="+", to="posthog.event"),+ ),+ migrations.AlterField(+ model_name="action",+ name="project",+ field=models.ForeignKey(+ blank=True,+ null=True,+ on_delete=django.db.models.deletion.CASCADE,+ related_name="+",+ to="posthog.project",+ ),+ ),+ migrations.AlterField(+ model_name="action",+ name="team",+ field=models.ForeignKey(+ on_delete=django.db.models.deletion.CASCADE,+ related_name="+",+ to="posthog.team",+ ),+ ),+ ]diff --git a/products/actions/backend/migrations/max_migration.txt b/products/actions/backend/migrations/max_migration.txtindex 6903cd5e3dc2..0da63b992d0e 100644--- a/products/actions/backend/migrations/max_migration.txt+++ b/products/actions/backend/migrations/max_migration.txt@@ -1 +1 @@-0001_squash_2026_09_07_initial+0002_alter_action_created_by_alter_action_events_and_morediff --git a/products/actions/backend/models/action.py b/products/actions/backend/models/action.pyindex a5ad78f8d744..6edd256dffea 100644--- a/products/actions/backend/models/action.py+++ b/products/actions/backend/models/action.py@@ -42,12 +42,12 @@ class ActionStepJSON:class Action(FileSystemSyncMixin, ModelActivityMixin, RootTeamMixin, models.Model):name = models.CharField(max_length=400, null=True, blank=True)description = models.TextField(blank=True, default="")- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)- project = models.ForeignKey("posthog.Project", on_delete=models.CASCADE, null=True, blank=True)+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")+ project = models.ForeignKey("posthog.Project", on_delete=models.CASCADE, null=True, blank=True, related_name="+")created_at = models.DateTimeField(auto_now_add=True, blank=True)- created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True)+ created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True, related_name="+")deleted = models.BooleanField(default=False)- events = models.ManyToManyField("posthog.Event", blank=True) # type: models.ManyToManyField+ events = models.ManyToManyField("posthog.Event", blank=True, related_name="+") # type: models.ManyToManyFieldpost_to_slack = models.BooleanField(default=False)slack_message_format = models.CharField(default="", max_length=1200, blank=True)updated_at = models.DateTimeField(auto_now=True)diff --git a/products/ai_observability/backend/migrations/0047_alter_evaluationconfig_team.py b/products/ai_observability/backend/migrations/0047_alter_evaluationconfig_team.pynew file mode 100644index 000000000000..818a8545fd28--- /dev/null+++ b/products/ai_observability/backend/migrations/0047_alter_evaluationconfig_team.py@@ -0,0 +1,28 @@+# Generated by Django 5.2.17 on 2026-09-10 07:52++import django.db.models.deletion+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ (+ "ai_observability",+ "0046_alter_aiobservabilitychecklistitemstate_team_and_more",+ ),+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),+ ]++ operations = [+ migrations.AlterField(+ model_name="evaluationconfig",+ name="team",+ field=models.OneToOneField(+ on_delete=django.db.models.deletion.CASCADE,+ primary_key=True,+ related_name="+",+ serialize=False,+ to="posthog.team",+ ),+ ),+ ]diff --git a/products/ai_observability/backend/migrations/max_migration.txt b/products/ai_observability/backend/migrations/max_migration.txtindex dbce5670f1d2..1fb81148bb6a 100644--- a/products/ai_observability/backend/migrations/max_migration.txt+++ b/products/ai_observability/backend/migrations/max_migration.txt@@ -1 +1 @@-0046_alter_aiobservabilitychecklistitemstate_team_and_more+0047_alter_evaluationconfig_teamdiff --git a/products/ai_observability/backend/models/evaluation_config.py b/products/ai_observability/backend/models/evaluation_config.pyindex 1a53efe9c4ee..dcc42e763b1f 100644--- a/products/ai_observability/backend/models/evaluation_config.py+++ b/products/ai_observability/backend/models/evaluation_config.py@@ -8,7 +8,7 @@ class EvaluationConfig(models.Model):"posthog.Team",on_delete=models.CASCADE,primary_key=True,- related_name="evaluation_config",+ related_name="+",)# Active BYOK key (single source of truth)diff --git a/products/canvas/backend/migrations/0020_alter_canvas_channel.py b/products/canvas/backend/migrations/0020_alter_canvas_channel.pynew file mode 100644index 000000000000..004d6e06dacf--- /dev/null+++ b/products/canvas/backend/migrations/0020_alter_canvas_channel.py@@ -0,0 +1,24 @@+# Generated by Django 5.2.17 on 2026-09-10 07:52++import django.db.models.deletion+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("canvas", "0019_alter_canvas_created_by_alter_canvas_team_and_more"),+ ("tasks", "0122_alter_desktopbetatermsacceptance_organization_and_more"),+ ]++ operations = [+ migrations.AlterField(+ model_name="canvas",+ name="channel",+ field=models.ForeignKey(+ db_constraint=False,+ on_delete=django.db.models.deletion.CASCADE,+ related_name="+",+ to="tasks.channel",+ ),+ ),+ ]diff --git a/products/canvas/backend/migrations/max_migration.txt b/products/canvas/backend/migrations/max_migration.txtindex e52f6170e88b..ceb10b4426c5 100644--- a/products/canvas/backend/migrations/max_migration.txt+++ b/products/canvas/backend/migrations/max_migration.txt@@ -1 +1 @@-0019_alter_canvas_created_by_alter_canvas_team_and_more+0020_alter_canvas_channeldiff --git a/products/canvas/backend/models.py b/products/canvas/backend/models.pyindex fff2de6e054e..d10dec6cde1a 100644--- a/products/canvas/backend/models.py+++ b/products/canvas/backend/models.py@@ -41,7 +41,7 @@ class Canvas(TeamScopedRootMixin, UUIDModel):# takes a parent lock during migration; scoping is enforced app-side.team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")# Channels are the tasks product's model; every canvas is filed into one.- channel = models.ForeignKey("tasks.Channel", on_delete=models.CASCADE, db_constraint=False, related_name="canvases")+ channel = models.ForeignKey("tasks.Channel", on_delete=models.CASCADE, db_constraint=False, related_name="+")name = models.CharField(max_length=400)kind = models.CharField(max_length=16, default=KIND_FREEFORM)diff --git a/products/data_modeling/backend/migrations/0037_alter_datawarehousesavedquery_folder_and_more.py b/products/data_modeling/backend/migrations/0037_alter_datawarehousesavedquery_folder_and_more.pynew file mode 100644index 000000000000..e1b6c8cad272--- /dev/null+++ b/products/data_modeling/backend/migrations/0037_alter_datawarehousesavedquery_folder_and_more.py@@ -0,0 +1,38 @@+# Generated by Django 5.2.17 on 2026-09-10 07:52++import django.db.models.deletion+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("data_modeling", "0036_alter_dag_team_and_more"),+ ("data_tools", "0002_alter_datawarehouseexpression_created_by_and_more"),+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),+ ]++ operations = [+ migrations.AlterField(+ model_name="datawarehousesavedquery",+ name="folder",+ field=models.ForeignKey(+ blank=True,+ help_text="Optional folder used to organize this saved query in the SQL editor sidebar.",+ null=True,+ on_delete=django.db.models.deletion.SET_NULL,+ related_name="+",+ to="data_tools.datawarehousesavedqueryfolder",+ ),+ ),+ migrations.AlterField(+ model_name="githubsyncconfig",+ name="team",+ field=models.OneToOneField(+ on_delete=django.db.models.deletion.CASCADE,+ primary_key=True,+ related_name="+",+ serialize=False,+ to="posthog.team",+ ),+ ),+ ]diff --git a/products/data_modeling/backend/migrations/max_migration.txt b/products/data_modeling/backend/migrations/max_migration.txtindex 5f56ee03e982..462b54823c85 100644--- a/products/data_modeling/backend/migrations/max_migration.txt+++ b/products/data_modeling/backend/migrations/max_migration.txt@@ -1 +1 @@-0036_alter_dag_team_and_more+0037_alter_datawarehousesavedquery_folder_and_morediff --git a/products/data_modeling/backend/models/datawarehouse_saved_query.py b/products/data_modeling/backend/models/datawarehouse_saved_query.pyindex 6d6e0b137950..d0c387f213b8 100644--- a/products/data_modeling/backend/models/datawarehouse_saved_query.py+++ b/products/data_modeling/backend/models/datawarehouse_saved_query.py@@ -146,7 +146,7 @@ class DataWarehouseSavedQuery(CreatedMetaFields, UUIDTModel, UpdatedMetaFields,on_delete=models.SET_NULL,null=True,blank=True,- related_name="saved_queries",+ related_name="+",help_text="Optional folder used to organize this saved query in the SQL editor sidebar.",)diff --git a/products/data_modeling/backend/models/github_sync_config.py b/products/data_modeling/backend/models/github_sync_config.pyindex 8568aba52e42..218e8bb1ee15 100644--- a/products/data_modeling/backend/models/github_sync_config.py+++ b/products/data_modeling/backend/models/github_sync_config.py@@ -16,7 +16,7 @@ class GitHubSyncStatus(models.TextChoices):class GitHubSyncConfig(CreatedMetaFields, UpdatedMetaFields):- team = models.OneToOneField(Team, on_delete=models.CASCADE, primary_key=True)+ team = models.OneToOneField(Team, on_delete=models.CASCADE, primary_key=True, related_name="+")team_id: intintegration = models.ForeignKey(diff --git a/products/data_warehouse/backend/presentation/views/saved_query.py b/products/data_warehouse/backend/presentation/views/saved_query.pyindex 6e5617fe3bc1..bb9bf4d472cf 100644--- a/products/data_warehouse/backend/presentation/views/saved_query.py+++ b/products/data_warehouse/backend/presentation/views/saved_query.py@@ -5,8 +5,8 @@ from typing import Any, castfrom django.conf import settingsfrom django.db import models, transaction-from django.db.models import Count, Model, OuterRef, Prefetch, Q, Subquery, TextField-from django.db.models.functions import Cast+from django.db.models import Count, IntegerField, Model, OuterRef, Prefetch, Q, Subquery, TextField+from django.db.models.functions import Cast, Coalesceimport structlogimport posthoganalytics@@ -1305,7 +1305,19 @@ class DataWarehouseSavedQueryFolderViewSet(TeamAndOrgViewSetMixin, AccessControlreturn (queryset.filter(team_id=self.team_id).select_related("created_by")- .annotate(view_count=Count("saved_queries", filter=Q(saved_queries__deleted=False)))+ .annotate(+ view_count=Coalesce(+ Subquery(+ DataWarehouseSavedQuery.objects.filter(folder=OuterRef("pk"), deleted=False)+ .order_by()+ .values("folder")+ .annotate(c=Count("id"))+ .values("c"),+ output_field=IntegerField(),+ ),+ 0,+ )+ ).order_by(self.ordering))@@ -1318,7 +1330,9 @@ class DataWarehouseSavedQueryFolderViewSet(TeamAndOrgViewSetMixin, AccessControlfolder: DataWarehouseSavedQueryFolder = self.get_object()remaining_queries = {saved_query.id: saved_query- for saved_query in folder.saved_queries.filter(deleted=False).select_related("managed_viewset", "folder")+ for saved_query in DataWarehouseSavedQuery.objects.filter(folder=folder, deleted=False).select_related(+ "managed_viewset", "folder"+ )}while remaining_queries:diff --git a/products/endpoints/backend/logic/materialization.py b/products/endpoints/backend/logic/materialization.pyindex c4d8033855c6..fc2c7bc1c110 100644--- a/products/endpoints/backend/logic/materialization.py+++ b/products/endpoints/backend/logic/materialization.py@@ -68,7 +68,7 @@ def prepare_executable_query(saved_query: DataWarehouseSavedQuery) -> None:Called by the data-modeling Temporal workflow before each materialization run,so query-printer changes and bucket overrides are always reflected."""- version = saved_query.endpoint_versions.first()+ version = EndpointVersion.objects.filter(saved_query=saved_query).first()if version is None:raise OrphanedEndpointSavedQueryError(f"Saved query {saved_query.id} ({saved_query.name}) has no linked EndpointVersion"@@ -308,7 +308,7 @@ class EndpointMaterializationService:)is_foreign = existing.origin != DataWarehouseSavedQuery.Origin.ENDPOINT or (- existing.endpoint_versions.exclude(pk=version.pk).exists()+ EndpointVersion.objects.filter(saved_query=existing).exclude(pk=version.pk).exists())if is_foreign:raise ValidationError(diff --git a/products/endpoints/backend/migrations/0033_alter_endpointversion_saved_query.py b/products/endpoints/backend/migrations/0033_alter_endpointversion_saved_query.pynew file mode 100644index 000000000000..e816384ca03d--- /dev/null+++ b/products/endpoints/backend/migrations/0033_alter_endpointversion_saved_query.py@@ -0,0 +1,27 @@+# Generated by Django 5.2.17 on 2026-09-10 07:52++import django.db.models.deletion+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("data_modeling", "0037_alter_datawarehousesavedquery_folder_and_more"),+ ("endpoints", "0032_alter_endpoint_created_by_alter_endpoint_team_and_more"),+ ]++ operations = [+ migrations.AlterField(+ model_name="endpointversion",+ name="saved_query",+ field=models.ForeignKey(+ blank=True,+ db_index=False,+ help_text="The underlying materialized view for this version",+ null=True,+ on_delete=django.db.models.deletion.SET_NULL,+ related_name="+",+ to="data_modeling.datawarehousesavedquery",+ ),+ ),+ ]diff --git a/products/endpoints/backend/migrations/max_migration.txt b/products/endpoints/backend/migrations/max_migration.txtindex 59e02ce7185f..ec353b94322e 100644--- a/products/endpoints/backend/migrations/max_migration.txt+++ b/products/endpoints/backend/migrations/max_migration.txt@@ -1 +1 @@-0032_alter_endpoint_created_by_alter_endpoint_team_and_more+0033_alter_endpointversion_saved_querydiff --git a/products/endpoints/backend/models.py b/products/endpoints/backend/models.pyindex e82f13822ffd..18cf59a5b7f4 100644--- a/products/endpoints/backend/models.py+++ b/products/endpoints/backend/models.py@@ -209,7 +209,7 @@ class EndpointVersion(UpdatedMetaFields, models.Model):blank=True,db_index=False,on_delete=models.SET_NULL,- related_name="endpoint_versions",+ related_name="+",help_text="The underlying materialized view for this version",)is_active = models.BooleanField(diff --git a/products/error_tracking/backend/migrations/0035_alter_errortrackingstackframe_team.py b/products/error_tracking/backend/migrations/0035_alter_errortrackingstackframe_team.pynew file mode 100644index 000000000000..b7d44d9e6291--- /dev/null+++ b/products/error_tracking/backend/migrations/0035_alter_errortrackingstackframe_team.py@@ -0,0 +1,23 @@+# Generated by Django 5.2.17 on 2026-09-10 07:52++import django.db.models.deletion+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("error_tracking", "0034_alter_errortrackingassignmentrule_role_and_more"),+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),+ ]++ operations = [+ migrations.AlterField(+ model_name="errortrackingstackframe",+ name="team",+ field=models.ForeignKey(+ on_delete=django.db.models.deletion.CASCADE,+ related_name="+",+ to="posthog.team",+ ),+ ),+ ]diff --git a/products/error_tracking/backend/migrations/max_migration.txt b/products/error_tracking/backend/migrations/max_migration.txtindex 001262b6acdc..2f718f67759e 100644--- a/products/error_tracking/backend/migrations/max_migration.txt+++ b/products/error_tracking/backend/migrations/max_migration.txt@@ -1 +1 @@-0034_alter_errortrackingassignmentrule_role_and_more+0035_alter_errortrackingstackframe_teamdiff --git a/products/error_tracking/backend/models.py b/products/error_tracking/backend/models.pyindex 16e533ebd332..bd54b34d77d9 100644--- a/products/error_tracking/backend/models.py+++ b/products/error_tracking/backend/models.py@@ -604,7 +604,7 @@ class ErrorTrackingStackFrame(UUIDTModel):raw_id = models.TextField(null=False, blank=False)# Raw frames could be resolved into multiple frames after demangling because of compilation processpart = models.IntegerField(null=False, default=0)- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")created_at = models.DateTimeField(auto_now_add=True)symbol_set = models.ForeignKey("ErrorTrackingSymbolSet", on_delete=models.SET_NULL, null=True)contents = models.JSONField(null=False, blank=False)diff --git a/products/experiments/backend/hogql_queries/test/test_funnel_step_builder_integration.py b/products/experiments/backend/hogql_queries/test/test_funnel_step_builder_integration.pyindex 41f807409bff..29fdd523af5b 100644--- a/products/experiments/backend/hogql_queries/test/test_funnel_step_builder_integration.py+++ b/products/experiments/backend/hogql_queries/test/test_funnel_step_builder_integration.py@@ -12,6 +12,7 @@ from posthog.schema import ActionsNode, EventsNode, ExperimentDataWarehouseNode,from posthog.hogql import astfrom posthog.hogql.parser import parse_expr+from products.actions.backend.models import Actionfrom products.experiments.backend.hogql_queries.funnel_step_builder import FunnelStepBuilder@@ -21,7 +22,7 @@ class TestFunnelStepBuilderIntegration(BaseTest):def test_mixed_node_types_integration(self):"""Test that FunnelStepBuilder handles mixed EventsNode and ActionsNode."""# Create an action first- action = self.team.action_set.create(name="Test Action")+ action = Action.objects.create(team=self.team, name="Test Action")series: list[EventsNode | ActionsNode | ExperimentDataWarehouseNode] = [EventsNode(event="pageview"),diff --git a/products/model_crossing_uses_baseline.txt b/products/model_crossing_uses_baseline.txtindex 8112f59db6c2..e78be0ccd59e 100644--- a/products/model_crossing_uses_baseline.txt+++ b/products/model_crossing_uses_baseline.txt@@ -43,10 +43,7 @@ dashboards.Dashboard posthog.SharingConfiguration.dashboard reverse-accessor(shadashboards.Dashboard posthog.TaggedItem.dashboard reverse-accessor(tagged_items) 1dashboards.Dashboard posthog.Team.primary_dashboard reverse-accessor(primary_dashboard_teams) 1dashboards.Dashboard product_analytics.Insight.dashboard reverse-accessor(items) 1-dashboards.Dashboard product_analytics.Insight.dive_dashboard reverse-accessor(insight_set) 1-data_modeling.DataWarehouseSavedQuery endpoints.EndpointVersion.saved_query reverse-accessor(endpoint_versions) 1data_modeling.DataWarehouseSavedQuery products.customer_analytics.backend.facade.api get_model 5-data_tools.DataWarehouseSavedQueryFolder data_modeling.DataWarehouseSavedQuery.folder reverse-accessor(saved_queries) 1endpoints.Endpoint posthog.TaggedItem.endpoint reverse-accessor(tagged_items) 1error_tracking.ErrorTrackingIssue products.demo.backend.logic.products.hedgebox.matrix get_model 1error_tracking.ErrorTrackingIssue products.posthog_ai.evals.error_tracking.seeders get_model 1@@ -89,11 +86,9 @@ metrics:backend/hogql_queries/ posthog.tasks.alerts.test.test_metrics_alerts drinotebooks.Notebook posthog.SharingConfiguration.notebook reverse-accessor(sharing_configurations) 1posthog.Comment conversations.EmailThreadMessage.comment reverse-accessor(email_thread_message) 1posthog.CoreEvent marketing_analytics.MarketingAnalyticsGoalMapping.core_event reverse-accessor(marketing_goal_mappings) 1-posthog.Event actions.Action.events reverse-accessor(action_set) 1posthog.Integration slack_app.SlackSettings.default_integration reverse-accessor(slack_settings_as_default) 1posthog.Integration slack_app.SlackThreadTaskMapping.integration reverse-accessor(slack_thread_task_mappings) 1posthog.Integration slack_app.SlackUserProfileCache.integration reverse-accessor(slack_user_profile_cache) 1-posthog.Integration tasks.SandboxSnapshot.integration reverse-accessor(snapshots) 1posthog.Organization access_control.OrganizationResourceAccess.organization reverse-accessor(resource_access) 1posthog.Organization access_control.Role.organization reverse-accessor(roles) 1posthog.Organization access_control.RoleExternalReference.organization reverse-accessor(role_external_references) 1@@ -107,17 +102,13 @@ posthog.Organization growth.ProductPushCampaign.organization reverse-accessor(prposthog.Organization legal_documents.LegalDocument.organization reverse-accessor(legal_documents) 1posthog.Organization managed_warehouse.DuckgresServer.organization reverse-accessor(duckgres_server) 1posthog.Organization managed_warehouse.ManagedWarehouseSourceLifecycle.organization reverse-accessor(managed_warehouse_source_lifecycle) 1-posthog.Organization replay_vision.ReplayObservationUsage.organization reverse-accessor(replay_observation_usage) 1posthog.OrganizationMembership access_control.AccessControl.organization_member reverse-accessor(access_controls) 1posthog.OrganizationMembership access_control.PropertyAccessControl.organization_member reverse-accessor(property_access_controls) 1posthog.OrganizationMembership access_control.RoleMembership.organization_member reverse-accessor(role_memberships) 1-posthog.Project actions.Action.project reverse-accessor(action_set) 1posthog.Team access_control.AccessControl.team reverse-accessor(access_controls) 1posthog.Team access_control.PropertyAccessControl.team reverse-accessor(property_access_controls) 1-posthog.Team actions.Action.team reverse-accessor(action_set) 1posthog.Team ai_observability.ClusteringConfig.team reverse-accessor(clustering_config) 1posthog.Team ai_observability.ClusteringJob.team reverse-accessor(clustering_jobs) 1-posthog.Team ai_observability.EvaluationConfig.team reverse-accessor(evaluation_config) 1posthog.Team alerts.AlertConfiguration.team reverse-accessor(alertconfiguration_set) 1posthog.Team batch_exports.BatchExportBackfill.team reverse-accessor(batchexportbackfill_set) 1posthog.Team business_knowledge.KnowledgeGapSuggestion.team reverse-accessor(business_knowledge_gap_suggestions) 1@@ -137,13 +128,11 @@ posthog.Team customer_analytics.TeamCustomerAnalyticsConfig.team reverse-accessoposthog.Team dashboards.Dashboard.team reverse-accessor(dashboard_set) 1posthog.Team dashboards.Text.team reverse-accessor(text_set) 1posthog.Team data_modeling.DataModelingJob.team reverse-accessor(datamodelingjob_set) 1-posthog.Team data_modeling.GitHubSyncConfig.team reverse-accessor(githubsyncconfig) 1posthog.Team data_warehouse.TeamDataWarehouseConfig.team reverse-accessor(teamdatawarehouseconfig) 1posthog.Team early_access_features.EarlyAccessFeature.team reverse-accessor(features) 1posthog.Team error_tracking.ErrorTrackingRecommendation.team reverse-accessor(error_tracking_recommendations) 1posthog.Team error_tracking.ErrorTrackingSettings.team reverse-accessor(error_tracking_settings) 1posthog.Team error_tracking.ErrorTrackingSpikeDetectionConfig.team reverse-accessor(error_tracking_spike_detection_config) 1-posthog.Team error_tracking.ErrorTrackingStackFrame.team reverse-accessor(errortrackingstackframe_set) 1posthog.Team event_definitions.EventDefinition.team reverse-accessor(event_definitions) 1posthog.Team event_definitions.PropertyDefinition.team reverse-accessor(property_definitions) 1posthog.Team event_definitions.SchemaPropertyGroup.team reverse-accessor(schema_property_groups) 1@@ -168,7 +157,6 @@ posthog.Team messaging.MessageTemplate.team reverse-accessor(messagetemplate_setposthog.Team messaging.OptOutSyncConfig.team reverse-accessor(optoutsyncconfig) 1posthog.Team posthog_ai.AgentMemory.team reverse-accessor(agent_memories) 1posthog.Team posthog_ai.CoreMemory.team reverse-accessor(corememory) 1-posthog.Team product_analytics.Insight.team reverse-accessor(insight_set) 1posthog.Team product_analytics.InsightViewed.team reverse-accessor(insightviewed_set) 1posthog.Team product_tours.ProductTour.team reverse-accessor(product_tours) 1posthog.Team pulse.BriefConfig.team reverse-accessor(briefconfig_set) 1@@ -183,7 +171,6 @@ posthog.Team signals.SignalScoutEmission.team reverse-accessor(signal_scout_emisposthog.Team signals.SignalScoutNote.team reverse-accessor(signal_scout_notes) 1posthog.Team signals.SignalScoutRun.team reverse-accessor(signal_scout_runs) 1posthog.Team signals.SignalScratchpad.team reverse-accessor(signal_scratchpads) 1-posthog.Team signals.SignalSourceConfig.team reverse-accessor(signal_source_configs) 1posthog.Team signals.SignalTeamConfig.team reverse-accessor(signal_team_config) 1posthog.Team slack_app.SlackThreadTaskMapping.team reverse-accessor(slack_thread_task_mappings) 1posthog.Team surveys.Survey.team reverse-accessor(surveys) 1@@ -201,7 +188,6 @@ posthog.User access_control.Role.created_by reverse-accessor(roles) 1posthog.User access_control.Role.members reverse-accessor(role_set) 1posthog.User access_control.RoleExternalReference.created_by reverse-accessor(roleexternalreference_set) 1posthog.User access_control.RoleMembership.user reverse-accessor(role_memberships) 1-posthog.User actions.Action.created_by reverse-accessor(action_set) 1posthog.User ai_observability.ParserRecipe.created_by reverse-accessor(parserrecipe_set) 1posthog.User ai_observability.ReviewQueue.created_by reverse-accessor(reviewqueue_set) 1posthog.User ai_observability.ReviewQueueItem.created_by reverse-accessor(reviewqueueitem_set) 1@@ -275,7 +261,6 @@ posthog.User notifications.NotificationArchiveState.user reverse-accessor(notifiposthog.User notifications.NotificationReadState.user reverse-accessor(notification_read_states) 1posthog.User posthog_ai.AgentArtifact.created_by reverse-accessor(agentartifact_set) 1posthog.User posthog_ai.AgentMemory.user reverse-accessor(agent_memories) 1-posthog.User product_analytics.Insight.created_by reverse-accessor(insight_set) 1posthog.User product_analytics.Insight.last_modified_by reverse-accessor(modified_insights) 1posthog.User product_analytics.InsightVariable.created_by reverse-accessor(insightvariable_set) 1posthog.User product_analytics.InsightViewed.user reverse-accessor(insightviewed_set) 1@@ -435,7 +420,6 @@ replay_vision.ReplayScanner posthog.TaggedItem.replay_scanner reverse-accessor(tsignals.SignalReport tasks.Task.signal_report reverse-accessor(task) 1surveys.Survey product_tours.ProductTour.linked_surveys reverse-accessor(product_tours) 1surveys.Survey products.early_access_features.backend.management.commands.migrate_enrollments_to_waitlist_surveys get_model 1-tasks.Channel canvas.Canvas.channel reverse-accessor(canvases) 1tasks.Task signals.SignalReportTask.task reverse-accessor(signal_report_tasks) 1tasks.Task slack_app.SlackThreadTaskMapping.task reverse-accessor(slack_thread_mappings) 1tasks.TaskRun products.review_hog.backend.receivers get_model 1diff --git a/products/product_analytics/backend/migrations/0010_alter_insight_created_by_and_more.py b/products/product_analytics/backend/migrations/0010_alter_insight_created_by_and_more.pynew file mode 100644index 000000000000..e7b829de1520--- /dev/null+++ b/products/product_analytics/backend/migrations/0010_alter_insight_created_by_and_more.py@@ -0,0 +1,51 @@+# Generated by Django 5.2.17 on 2026-09-10 07:52++import django.db.models.deletion+from django.conf import settings+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ (+ "dashboards",+ "0019_alter_buttontile_created_by_alter_buttontile_team_and_more",+ ),+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),+ ("product_analytics", "0009_alter_insightvariable_team"),+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),+ ]++ operations = [+ migrations.AlterField(+ model_name="insight",+ name="created_by",+ field=models.ForeignKey(+ blank=True,+ null=True,+ on_delete=django.db.models.deletion.SET_NULL,+ related_name="+",+ to=settings.AUTH_USER_MODEL,+ ),+ ),+ migrations.AlterField(+ model_name="insight",+ name="dive_dashboard",+ field=models.ForeignKey(+ blank=True,+ null=True,+ on_delete=django.db.models.deletion.SET_NULL,+ related_name="+",+ to="dashboards.dashboard",+ ),+ ),+ migrations.AlterField(+ model_name="insight",+ name="team",+ field=models.ForeignKey(+ on_delete=django.db.models.deletion.CASCADE,+ related_name="+",+ to="posthog.team",+ ),+ ),+ ]diff --git a/products/product_analytics/backend/migrations/max_migration.txt b/products/product_analytics/backend/migrations/max_migration.txtindex d09ebcaed57c..c6c709297ebe 100644--- a/products/product_analytics/backend/migrations/max_migration.txt+++ b/products/product_analytics/backend/migrations/max_migration.txt@@ -1 +1 @@-0009_alter_insightvariable_team+0010_alter_insight_created_by_and_morediff --git a/products/product_analytics/backend/models/insight.py b/products/product_analytics/backend/models/insight.pyindex e9789228c213..cd1b226bcfce 100644--- a/products/product_analytics/backend/models/insight.py+++ b/products/product_analytics/backend/models/insight.py@@ -66,7 +66,7 @@ class Insight(RootTeamMixin, FileSystemSyncMixin, models.Model):name = models.CharField(max_length=400, null=True, blank=True)derived_name = models.CharField(max_length=400, null=True, blank=True)description = models.CharField(max_length=400, null=True, blank=True)- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")filters = models.JSONField(default=dict)filters_hash = models.CharField(max_length=400, null=True, blank=True)query = models.JSONField(null=True, blank=True)@@ -77,7 +77,7 @@ class Insight(RootTeamMixin, FileSystemSyncMixin, models.Model):saved = models.BooleanField(default=True)created_at = models.DateTimeField(null=True, blank=True, auto_now_add=True)refreshing = models.BooleanField(default=False)- created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True)+ created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True, related_name="+")# Indicates if it's a sample graph generated by dashboard templatesis_sample = models.BooleanField(default=False)# Unique ID per team for easy sharing and short links@@ -108,7 +108,9 @@ class Insight(RootTeamMixin, FileSystemSyncMixin, models.Model):# DEPRECATED: on dashboard_insight nowcolor = models.CharField(max_length=400, null=True, blank=True)# DEPRECATED: dive dashboards were never shipped- dive_dashboard = models.ForeignKey("dashboards.Dashboard", on_delete=models.SET_NULL, null=True, blank=True)+ dive_dashboard = models.ForeignKey(+ "dashboards.Dashboard", on_delete=models.SET_NULL, null=True, blank=True, related_name="+"+ )# DEPRECATED: in practically all cases field `last_modified_at` should be used insteadupdated_at = models.DateTimeField(auto_now=True)# DEPRECATED: use `display` property of the Filter object insteaddiff --git a/products/replay_vision/backend/migrations/0094_alter_replayobservationusage_organization.py b/products/replay_vision/backend/migrations/0094_alter_replayobservationusage_organization.pynew file mode 100644index 000000000000..7a56f613ec2d--- /dev/null+++ b/products/replay_vision/backend/migrations/0094_alter_replayobservationusage_organization.py@@ -0,0 +1,23 @@+# Generated by Django 5.2.17 on 2026-09-10 07:52++import django.db.models.deletion+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),+ ("replay_vision", "0093_drop_visionaction_tables"),+ ]++ operations = [+ migrations.AlterField(+ model_name="replayobservationusage",+ name="organization",+ field=models.ForeignKey(+ on_delete=django.db.models.deletion.CASCADE,+ related_name="+",+ to="posthog.organization",+ ),+ ),+ ]diff --git a/products/replay_vision/backend/migrations/max_migration.txt b/products/replay_vision/backend/migrations/max_migration.txtindex c60035d4be91..9f2eef06bebe 100644--- a/products/replay_vision/backend/migrations/max_migration.txt+++ b/products/replay_vision/backend/migrations/max_migration.txt@@ -1 +1 @@-0093_drop_visionaction_tables+0094_alter_replayobservationusage_organizationdiff --git a/products/replay_vision/backend/models/replay_observation_usage.py b/products/replay_vision/backend/models/replay_observation_usage.pyindex 40f4297d65c0..0682bd133435 100644--- a/products/replay_vision/backend/models/replay_observation_usage.py+++ b/products/replay_vision/backend/models/replay_observation_usage.py@@ -13,7 +13,7 @@ class ReplayObservationUsage(UUIDModel):organization = models.ForeignKey("posthog.Organization",on_delete=models.CASCADE,- related_name="replay_observation_usage",+ related_name="+",)observation_id = models.UUIDField(unique=True,diff --git a/products/signals/ARCHITECTURE.md b/products/signals/ARCHITECTURE.mdindex 5df2949d54a4..46624464b6f8 100644--- a/products/signals/ARCHITECTURE.md+++ b/products/signals/ARCHITECTURE.md@@ -543,7 +543,7 @@ Per-team configuration for which signal sources are enabled.| Field | Type | Description || ---------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |-| `team` | FK → Team | Owning team (`related_name="signal_source_configs"`) |+| `team` | FK → Team | Owning team (reverse accessor sealed with `related_name="+"`) || `source_product` | CharField | One of: `session_replay`, `llm_analytics`, `github`, `linear`, `zendesk`, `conversations`, `error_tracking`, `signals_scout` (`SourceProduct` enum) || `source_type` | CharField | One of: `session_analysis_cluster`, `evaluation_report`, `issue`, `ticket`, `issue_created`, `issue_reopened`, `issue_spiking`, `cross_source_issue` (`SourceType` enum) || `enabled` | Boolean | Whether this source is active (default `True`) |diff --git a/products/signals/backend/migrations/0123_alter_signalsourceconfig_team.py b/products/signals/backend/migrations/0123_alter_signalsourceconfig_team.pynew file mode 100644index 000000000000..c3fbf2fd6897--- /dev/null+++ b/products/signals/backend/migrations/0123_alter_signalsourceconfig_team.py@@ -0,0 +1,23 @@+# Generated by Django 5.2.17 on 2026-09-10 07:52++import django.db.models.deletion+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),+ ("signals", "0122_alter_signalemissionrecord_team_and_more"),+ ]++ operations = [+ migrations.AlterField(+ model_name="signalsourceconfig",+ name="team",+ field=models.ForeignKey(+ on_delete=django.db.models.deletion.CASCADE,+ related_name="+",+ to="posthog.team",+ ),+ ),+ ]diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txtindex 80206808045e..1d3bdb3981bb 100644--- a/products/signals/backend/migrations/max_migration.txt+++ b/products/signals/backend/migrations/max_migration.txt@@ -1 +1 @@-0122_alter_signalemissionrecord_team_and_more+0123_alter_signalsourceconfig_teamdiff --git a/products/signals/backend/models.py b/products/signals/backend/models.pyindex 05b9fde62454..06eb8517329f 100644--- a/products/signals/backend/models.py+++ b/products/signals/backend/models.py@@ -90,7 +90,7 @@ class SignalSourceConfig(UUIDModel):CI_DURATION_REGRESSION = "ci_duration_regression", "CI duration regression"SEARCH_OPPORTUNITY = "search_opportunity", "Search opportunity"- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="signal_source_configs")+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")source_product = models.CharField(max_length=100, choices=signal_source_product_choices)source_type = models.CharField(max_length=100, choices=signal_source_type_choices)enabled = models.BooleanField(default=True)diff --git a/products/tasks/backend/facade/api.py b/products/tasks/backend/facade/api.pyindex cbefa398c0a7..caa0bfe6a04d 100644--- a/products/tasks/backend/facade/api.py+++ b/products/tasks/backend/facade/api.py@@ -51,6 +51,7 @@ from posthog.models.integration import Integrationfrom posthog.models.oauth import OAuthAccessToken, OAuthRefreshTokenfrom posthog.utils import absolute_uri+from products.canvas.backend.models import Canvasfrom products.posthog_ai.backend.task_ownership import detach_conversations_for_task_handofffrom products.tasks.backend.constants import (AGENT_OTEL_TELEMETRY_STATE_KEY,@@ -8371,7 +8372,7 @@ def delete_channel(channel_id: str | UUID, team_id: int, user_id: int | None) ->return "general"if (channel.tasks.filter(deleted=False, archived=False).exists()- or channel.canvases.filter(deleted=False).exists()+ or Canvas.objects.filter(channel=channel, deleted=False).exists()):return "not_empty"diff --git a/products/tasks/backend/migrations/0123_alter_sandboxsnapshot_integration.py b/products/tasks/backend/migrations/0123_alter_sandboxsnapshot_integration.pynew file mode 100644index 000000000000..44e5215c68bd--- /dev/null+++ b/products/tasks/backend/migrations/0123_alter_sandboxsnapshot_integration.py@@ -0,0 +1,25 @@+# Generated by Django 5.2.17 on 2026-09-10 07:52++import django.db.models.deletion+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),+ ("tasks", "0122_alter_desktopbetatermsacceptance_organization_and_more"),+ ]++ operations = [+ migrations.AlterField(+ model_name="sandboxsnapshot",+ name="integration",+ field=models.ForeignKey(+ blank=True,+ null=True,+ on_delete=django.db.models.deletion.SET_NULL,+ related_name="+",+ to="posthog.integration",+ ),+ ),+ ]diff --git a/products/tasks/backend/migrations/max_migration.txt b/products/tasks/backend/migrations/max_migration.txtindex 7c77f62deb5c..b8b362186932 100644--- a/products/tasks/backend/migrations/max_migration.txt+++ b/products/tasks/backend/migrations/max_migration.txt@@ -1 +1 @@-0122_alter_desktopbetatermsacceptance_organization_and_more+0123_alter_sandboxsnapshot_integrationdiff --git a/products/tasks/backend/models.py b/products/tasks/backend/models.pyindex 5abe1572103b..05c0e0abd305 100644--- a/products/tasks/backend/models.py+++ b/products/tasks/backend/models.py@@ -3452,7 +3452,7 @@ class SandboxSnapshot(UUIDModel):integration = models.ForeignKey(Integration,on_delete=models.SET_NULL,- related_name="snapshots",+ related_name="+",null=True,blank=True,)