Skip to content

: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.

chore(devex): seal unused cross-boundary reverse accessors (#91593)

Julian Bez7d6a3b918d7b
diff --git a/posthog/migrations/1350_alter_userscenepersonalisation_dashboard.py b/posthog/migrations/1350_alter_userscenepersonalisation_dashboard.py
new file mode 100644
index 000000000000..68a210bd2d01
--- /dev/null
+++ b/posthog/migrations/1350_alter_userscenepersonalisation_dashboard.py
@@ -0,0 +1,28 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ (
+ "dashboards",
+ "0019_alter_buttontile_created_by_alter_buttontile_team_and_more",
+ ),
+ ("posthog", "1349_delete_persistedfolder_from_state"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="userscenepersonalisation",
+ name="dashboard",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="dashboards.dashboard",
+ ),
+ ),
+ ]
diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txt
index 8717eaf8ac17..b62675790611 100644
--- a/posthog/migrations/max_migration.txt
+++ b/posthog/migrations/max_migration.txt
@@ -1 +1 @@
-1349_delete_persistedfolder_from_state
+1350_alter_userscenepersonalisation_dashboard
diff --git a/posthog/models/group_type_mapping.py b/posthog/models/group_type_mapping.py
index 24811ddd8ce4..ed644a592317 100644
--- a/posthog/models/group_type_mapping.py
+++ b/posthog/models/group_type_mapping.py
@@ -124,7 +124,12 @@ class GroupTypeMapping(RootTeamMixin, models.Model):
# DO_NOTHING + db_constraint=False: Dashboard deletion handled manually, may be cross-database
detail_dashboard = field_access_control(
models.ForeignKey(
- "dashboards.Dashboard", on_delete=models.DO_NOTHING, db_constraint=False, null=True, blank=True
+ "dashboards.Dashboard",
+ on_delete=models.DO_NOTHING,
+ db_constraint=False,
+ null=True,
+ blank=True,
+ related_name="+",
),
"project",
"admin",
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.ambr
index a2aee91c4085..502feb62545a 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
@@ -524,7 +524,6 @@
'created_by_id',
'enqueue_calculation',
'errors_calculating',
- 'errortrackingissuecohort_set',
'experiment_set',
'filters_shape_hash',
'get_analytics_metadata',
@@ -573,14 +572,11 @@
'__str__',
'_meta',
'analytics_dashboards',
- 'annotation_set',
'created_by_id',
'data_color_theme',
'data_color_theme_id',
'delete',
'exportedasset_set',
- 'featureflag_set',
- 'featureflagdashboards_set',
'get_analytics_metadata',
'get_creation_mode_display',
'get_file_system_representation',
@@ -588,7 +584,6 @@
'get_next_by_created_at',
'get_previous_by_created_at',
'get_restriction_level_display',
- 'grouptypemapping_set',
'id',
'insight_set',
'is_shared',
@@ -602,12 +597,10 @@
'privileges',
'share_token',
'sharingconfiguration_set',
- 'subscription_set',
'tagged_items',
'team_id',
'tiles',
'url',
- 'userscenepersonalisation_set',
])
# ---
# name: TestVisitorFieldSnapshots.test_skipped_fields_DashboardTile
@@ -893,12 +886,9 @@
'__str__',
'_meta',
'_unwrapped_query_kind',
- 'alert_set',
'alertable_query_kind',
'alertconfiguration_set',
- 'annotation_set',
'created_by_id',
- 'customerjourney_set',
'dashboard',
'dashboard_filters',
'dashboard_id',
@@ -933,12 +923,10 @@
'sharingconfiguration_set',
'short_id',
'show_legend',
- 'subscription_set',
'subscriptions_dashboard_export',
'surveys_linked_insight',
'tagged_items',
'team_id',
- 'threshold_set',
'type',
'url',
])
diff --git a/posthog/models/user_scene_personalisation.py b/posthog/models/user_scene_personalisation.py
index 26d5be604362..d9174a07edbc 100644
--- a/posthog/models/user_scene_personalisation.py
+++ b/posthog/models/user_scene_personalisation.py
@@ -5,7 +5,9 @@ from posthog.models.utils import RootTeamMixin, UUIDTModel
class UserScenePersonalisation(UUIDTModel, RootTeamMixin):
scene = models.CharField(max_length=200)
- dashboard = models.ForeignKey("dashboards.Dashboard", on_delete=models.CASCADE, null=True, blank=True)
+ dashboard = models.ForeignKey(
+ "dashboards.Dashboard", on_delete=models.CASCADE, null=True, blank=True, related_name="+"
+ )
team = models.ForeignKey("Team", on_delete=models.CASCADE, null=True, blank=True)
user = models.ForeignKey(
"User",
diff --git a/products/access_control/backend/migrations/0002_alter_propertyaccesscontrol_created_by.py b/products/access_control/backend/migrations/0002_alter_propertyaccesscontrol_created_by.py
new file mode 100644
index 000000000000..aed5de19c917
--- /dev/null
+++ b/products/access_control/backend/migrations/0002_alter_propertyaccesscontrol_created_by.py
@@ -0,0 +1,25 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("access_control", "0001_squash_2026_09_07_initial"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="propertyaccesscontrol",
+ name="created_by",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ]
diff --git a/products/access_control/backend/migrations/max_migration.txt b/products/access_control/backend/migrations/max_migration.txt
index 6903cd5e3dc2..fbe0e56a1ac4 100644
--- a/products/access_control/backend/migrations/max_migration.txt
+++ b/products/access_control/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_squash_2026_09_07_initial
+0002_alter_propertyaccesscontrol_created_by
diff --git a/products/access_control/backend/models/property_access_control.py b/products/access_control/backend/models/property_access_control.py
index 48355ec65f54..cc32b7acd627 100644
--- a/products/access_control/backend/models/property_access_control.py
+++ b/products/access_control/backend/models/property_access_control.py
@@ -48,10 +48,6 @@ class PropertyAccessControl(UUIDModel):
)
# metadata
- created_by = models.ForeignKey(
- "posthog.User",
- on_delete=models.SET_NULL,
- null=True,
- )
+ created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, related_name="+")
created_at: models.DateTimeField = models.DateTimeField(auto_now_add=True)
updated_at: models.DateTimeField = models.DateTimeField(auto_now=True)
diff --git a/products/ai_observability/backend/migrations/0046_alter_aiobservabilitychecklistitemstate_team_and_more.py b/products/ai_observability/backend/migrations/0046_alter_aiobservabilitychecklistitemstate_team_and_more.py
new file mode 100644
index 000000000000..23b6d7f900be
--- /dev/null
+++ b/products/ai_observability/backend/migrations/0046_alter_aiobservabilitychecklistitemstate_team_and_more.py
@@ -0,0 +1,318 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("ai_observability", "0045_squash_2026_09_07_schema_addons"),
+ ("posthog", "1349_delete_persistedfolder_from_state"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="aiobservabilitychecklistitemstate",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="dataset",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="dataset",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datasetitem",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datasetitem",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datasetitemversion",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datasetitemversion",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datasetrevision",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datasetrevision",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="evaluation",
+ 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="evaluation",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="evaluationdirectory",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="evaluationreport",
+ 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="evaluationreport",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="llmmodelconfiguration",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="llmprompt",
+ 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="llmprompt",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="llmpromptlabel",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="llmpromptlabel",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="llmproviderkey",
+ 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="llmproviderkey",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="llmtracesummary",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="parserrecipe",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="reviewqueue",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="reviewqueueitem",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="scoredefinition",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="tagger",
+ 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="tagger",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="tracereview",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="tracereviewscore",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/ai_observability/backend/migrations/max_migration.txt b/products/ai_observability/backend/migrations/max_migration.txt
index 9b645a42a400..dbce5670f1d2 100644
--- a/products/ai_observability/backend/migrations/max_migration.txt
+++ b/products/ai_observability/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0045_squash_2026_09_07_schema_addons
+0046_alter_aiobservabilitychecklistitemstate_team_and_more
diff --git a/products/ai_observability/backend/models/datasets.py b/products/ai_observability/backend/models/datasets.py
index 68c201c5329f..79b2db1714e5 100644
--- a/products/ai_observability/backend/models/datasets.py
+++ b/products/ai_observability/backend/models/datasets.py
@@ -24,13 +24,9 @@ def _json_type_is_not(field_name: str, json_type: str) -> NegatedExpression:
class Dataset(UUIDModel, CreatedMetaFields, UpdatedMetaFields):
objects = TeamScopedManager()
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User",
- on_delete=models.SET_NULL,
- null=True,
- blank=True,
- db_constraint=False,
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
name = models.CharField(max_length=400)
@@ -76,13 +72,9 @@ class Dataset(UUIDModel, CreatedMetaFields, UpdatedMetaFields):
class DatasetRevision(UUIDModel, CreatedMetaFields):
objects = TeamScopedManager()
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User",
- on_delete=models.SET_NULL,
- null=True,
- blank=True,
- db_constraint=False,
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
dataset = models.ForeignKey(Dataset, on_delete=models.CASCADE, related_name="revisions")
@@ -110,13 +102,9 @@ class DatasetRevision(UUIDModel, CreatedMetaFields):
class DatasetItem(UUIDModel, CreatedMetaFields, UpdatedMetaFields):
objects = TeamScopedManager()
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User",
- on_delete=models.SET_NULL,
- null=True,
- blank=True,
- db_constraint=False,
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
dataset = models.ForeignKey(Dataset, on_delete=models.CASCADE, related_name="items")
@@ -154,13 +142,9 @@ class DatasetItem(UUIDModel, CreatedMetaFields, UpdatedMetaFields):
class DatasetItemVersion(UUIDModel, CreatedMetaFields):
objects = TeamScopedManager()
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User",
- on_delete=models.SET_NULL,
- null=True,
- blank=True,
- db_constraint=False,
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
dataset = models.ForeignKey(Dataset, on_delete=models.CASCADE, related_name="item_versions")
diff --git a/products/ai_observability/backend/models/evaluation_directories.py b/products/ai_observability/backend/models/evaluation_directories.py
index 1cd041cf277c..d1d1aaf7b969 100644
--- a/products/ai_observability/backend/models/evaluation_directories.py
+++ b/products/ai_observability/backend/models/evaluation_directories.py
@@ -9,7 +9,7 @@ from posthog.models.utils import CreatedMetaFields, UpdatedMetaFields, UUIDModel
class EvaluationDirectory(ModelActivityMixin, TeamScopedRootMixin, UUIDModel, CreatedMetaFields, UpdatedMetaFields):
activity_logging_on_delete = True
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
name = models.CharField(max_length=400)
created_by = models.ForeignKey(
"posthog.User",
diff --git a/products/ai_observability/backend/models/evaluation_reports.py b/products/ai_observability/backend/models/evaluation_reports.py
index 8e8d44258b80..f6807f2c28af 100644
--- a/products/ai_observability/backend/models/evaluation_reports.py
+++ b/products/ai_observability/backend/models/evaluation_reports.py
@@ -63,7 +63,7 @@ class EvaluationReport(UUIDTModel):
models.UniqueConstraint(fields=["evaluation"], name="unique_evaluation_report_per_evaluation"),
]
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
evaluation = models.ForeignKey(
"ai_observability.Evaluation",
on_delete=models.CASCADE,
@@ -107,7 +107,7 @@ class EvaluationReport(UUIDTModel):
# Lets users steer focus/scope/section choices without touching the base prompt.
report_prompt_guidance = models.TextField(blank=True, default="")
- 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="+")
created_at = models.DateTimeField(auto_now_add=True)
@property
diff --git a/products/ai_observability/backend/models/evaluations.py b/products/ai_observability/backend/models/evaluations.py
index 501e29a1499f..8a479ad74242 100644
--- a/products/ai_observability/backend/models/evaluations.py
+++ b/products/ai_observability/backend/models/evaluations.py
@@ -83,7 +83,7 @@ class Evaluation(ModelActivityMixin, UUIDTModel):
objects = EvaluationQuerySet.as_manager()
# Core fields
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
name = models.CharField(max_length=400)
description = models.TextField(blank=True, default="")
directory = models.ForeignKey(
@@ -135,7 +135,7 @@ class Evaluation(ModelActivityMixin, UUIDTModel):
# Timestamps
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=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)
def __init__(self, *args, **kwargs) -> None:
diff --git a/products/ai_observability/backend/models/instrumentation_checklist.py b/products/ai_observability/backend/models/instrumentation_checklist.py
index 2445a6e09438..c80740ee3f4d 100644
--- a/products/ai_observability/backend/models/instrumentation_checklist.py
+++ b/products/ai_observability/backend/models/instrumentation_checklist.py
@@ -14,7 +14,7 @@ class AIObservabilityChecklistItemState(TeamScopedRootMixin, UUIDModel):
class Status(models.TextChoices):
DISMISSED = "dismissed", "Dismissed"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
check_key = models.CharField(max_length=64)
# Null means project-wide. Reserved for per-workload checklists.
scope = models.CharField(max_length=200, null=True, blank=True)
diff --git a/products/ai_observability/backend/models/llm_prompt.py b/products/ai_observability/backend/models/llm_prompt.py
index 66a05d256f1d..5d4942af6066 100644
--- a/products/ai_observability/backend/models/llm_prompt.py
+++ b/products/ai_observability/backend/models/llm_prompt.py
@@ -56,13 +56,8 @@ class LLMPrompt(UUIDModel):
# Optional "what changed" note set when the version is published; immutable like the rest of the row
version_description = models.CharField(max_length=400, null=True, blank=True)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
- created_by = models.ForeignKey(
- "posthog.User",
- on_delete=models.SET_NULL,
- null=True,
- blank=True,
- )
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
+ created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True, related_name="+")
created_at = models.DateTimeField(default=timezone.now)
updated_at = models.DateTimeField(auto_now=True)
@@ -102,13 +97,9 @@ class LLMPromptLabel(ModelActivityMixin, UUIDModel):
# db_constraint=False: posthog_team / posthog_user are hot tables — adding a real FK
# constraint locks the parent table during migration.
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User",
- on_delete=models.SET_NULL,
- null=True,
- blank=True,
- db_constraint=False,
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
created_at = models.DateTimeField(default=timezone.now)
diff --git a/products/ai_observability/backend/models/llm_traces_summaries.py b/products/ai_observability/backend/models/llm_traces_summaries.py
index 3cfda948c6e9..6eb7afb651e2 100644
--- a/products/ai_observability/backend/models/llm_traces_summaries.py
+++ b/products/ai_observability/backend/models/llm_traces_summaries.py
@@ -20,7 +20,7 @@ class LLMTraceSummary(UUIDTModel):
ISSUES_SEARCH = "issues_search"
- 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, null=True)
updated_at = models.DateTimeField(auto_now=True, null=True)
trace_summary_type = models.CharField(
diff --git a/products/ai_observability/backend/models/model_configuration.py b/products/ai_observability/backend/models/model_configuration.py
index ae19395b95af..1c7d199bdc27 100644
--- a/products/ai_observability/backend/models/model_configuration.py
+++ b/products/ai_observability/backend/models/model_configuration.py
@@ -19,7 +19,7 @@ def provider_requires_key(provider: str) -> bool:
class LLMModelConfiguration(UUIDTModel):
"""Configuration for LLM model selection, used by evals and other features."""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
provider = models.CharField(max_length=50, choices=llm_provider_choices)
model = models.CharField(max_length=100)
provider_key = models.ForeignKey(
diff --git a/products/ai_observability/backend/models/parser_recipe.py b/products/ai_observability/backend/models/parser_recipe.py
index 183fcec11a6d..ce74c3938387 100644
--- a/products/ai_observability/backend/models/parser_recipe.py
+++ b/products/ai_observability/backend/models/parser_recipe.py
@@ -13,7 +13,7 @@ class ParserRecipe(TeamScopedRootMixin, UUIDModel, CreatedMetaFields, UpdatedMet
trace view; the frontend owns the merge against its bundled defaults.
"""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
name = models.CharField(max_length=255)
source = models.TextField()
diff --git a/products/ai_observability/backend/models/provider_keys.py b/products/ai_observability/backend/models/provider_keys.py
index 3fbc337daa74..b98abb31da22 100644
--- a/products/ai_observability/backend/models/provider_keys.py
+++ b/products/ai_observability/backend/models/provider_keys.py
@@ -36,14 +36,14 @@ class LLMProviderKey(UUIDTModel):
INVALID = "invalid"
ERROR = "error"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
provider = models.CharField(max_length=50, choices=llm_provider_choices)
name = models.CharField(max_length=255)
state = models.CharField(max_length=20, choices=State, default=State.UNKNOWN)
error_message = models.TextField(null=True, blank=True)
encrypted_config = EncryptedJSONField(default=dict, ignore_decrypt_errors=True)
created_at = models.DateTimeField(auto_now_add=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="+")
last_used_at = models.DateTimeField(null=True, blank=True)
class Meta:
diff --git a/products/ai_observability/backend/models/review_queues.py b/products/ai_observability/backend/models/review_queues.py
index b9ee161b008b..d28449d00353 100644
--- a/products/ai_observability/backend/models/review_queues.py
+++ b/products/ai_observability/backend/models/review_queues.py
@@ -9,7 +9,7 @@ from posthog.models.utils import CreatedMetaFields, DeletedMetaFields, UpdatedMe
class ReviewQueue(UUIDModel, CreatedMetaFields, UpdatedMetaFields, DeletedMetaFields):
objects: models.Manager["ReviewQueue"]
- team = models.ForeignKey(Team, on_delete=models.CASCADE)
+ team = models.ForeignKey(Team, on_delete=models.CASCADE, related_name="+")
name = models.CharField(max_length=255)
class Meta:
@@ -45,7 +45,7 @@ class ReviewQueue(UUIDModel, CreatedMetaFields, UpdatedMetaFields, DeletedMetaFi
class ReviewQueueItem(UUIDModel, CreatedMetaFields, UpdatedMetaFields, DeletedMetaFields):
objects: models.Manager["ReviewQueueItem"]
- team = models.ForeignKey(Team, on_delete=models.CASCADE)
+ team = models.ForeignKey(Team, on_delete=models.CASCADE, related_name="+")
queue = models.ForeignKey(ReviewQueue, on_delete=models.CASCADE, related_name="items")
trace_id = models.CharField(max_length=255)
diff --git a/products/ai_observability/backend/models/score_definitions.py b/products/ai_observability/backend/models/score_definitions.py
index 7c1e6fc74517..677591b8c11c 100644
--- a/products/ai_observability/backend/models/score_definitions.py
+++ b/products/ai_observability/backend/models/score_definitions.py
@@ -23,7 +23,7 @@ class ScoreDefinition(UUIDModel, CreatedMetaFields, UpdatedMetaFields):
NUMERIC = "numeric", "numeric"
BOOLEAN = "boolean", "boolean"
- team = models.ForeignKey(Team, on_delete=models.CASCADE)
+ team = models.ForeignKey(Team, on_delete=models.CASCADE, related_name="+")
name = models.CharField(max_length=255)
description = models.TextField(blank=True, default="")
kind = models.CharField(max_length=32, choices=Kind)
diff --git a/products/ai_observability/backend/models/taggers.py b/products/ai_observability/backend/models/taggers.py
index 23c1764af0a8..4fdfd26348d7 100644
--- a/products/ai_observability/backend/models/taggers.py
+++ b/products/ai_observability/backend/models/taggers.py
@@ -115,7 +115,7 @@ class Tagger(UUIDTModel):
]
# Core fields
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
name = models.CharField(max_length=400)
description = models.TextField(blank=True, default="")
enabled = models.BooleanField(default=False)
@@ -140,7 +140,7 @@ class Tagger(UUIDTModel):
# Timestamps
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=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)
def __str__(self):
diff --git a/products/ai_observability/backend/models/trace_reviews.py b/products/ai_observability/backend/models/trace_reviews.py
index 2659c4c84e20..2730a37b5d7d 100644
--- a/products/ai_observability/backend/models/trace_reviews.py
+++ b/products/ai_observability/backend/models/trace_reviews.py
@@ -10,7 +10,7 @@ from .score_definitions import ScoreDefinition
class TraceReview(UUIDModel, CreatedMetaFields, UpdatedMetaFields, DeletedMetaFields):
- team = models.ForeignKey(Team, on_delete=models.CASCADE)
+ team = models.ForeignKey(Team, on_delete=models.CASCADE, related_name="+")
trace_id = models.CharField(max_length=255)
reviewed_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True, related_name="+")
comment = models.TextField(null=True, blank=True)
@@ -32,7 +32,7 @@ class TraceReview(UUIDModel, CreatedMetaFields, UpdatedMetaFields, DeletedMetaFi
class TraceReviewScore(UUIDModel, CreatedMetaFields, UpdatedMetaFields):
- team = models.ForeignKey(Team, on_delete=models.CASCADE)
+ team = models.ForeignKey(Team, on_delete=models.CASCADE, related_name="+")
review = models.ForeignKey(TraceReview, on_delete=models.CASCADE, related_name="scores")
definition = models.ForeignKey(ScoreDefinition, on_delete=models.CASCADE, related_name="trace_review_scores")
definition_version = models.UUIDField()
diff --git a/products/alerts/backend/migrations/0006_alter_alert_insight_alter_alert_team_and_more.py b/products/alerts/backend/migrations/0006_alter_alert_insight_alter_alert_team_and_more.py
new file mode 100644
index 000000000000..f3aa2fc2bd0f
--- /dev/null
+++ b/products/alerts/backend/migrations/0006_alter_alert_insight_alter_alert_team_and_more.py
@@ -0,0 +1,51 @@
+# Generated by Django 5.2.17 on 2026-09-10 08:27
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("alerts", "0005_alertconfiguration_schedule_start_time"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ("product_analytics", "0009_alter_insightvariable_team"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="alert",
+ name="insight",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="product_analytics.insight",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="alert",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="threshold",
+ name="insight",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="product_analytics.insight",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="threshold",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/alerts/backend/migrations/max_migration.txt b/products/alerts/backend/migrations/max_migration.txt
index 865616773c2d..f5c8b630d573 100644
--- a/products/alerts/backend/migrations/max_migration.txt
+++ b/products/alerts/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0005_alertconfiguration_schedule_start_time
+0006_alter_alert_insight_alter_alert_team_and_more
diff --git a/products/alerts/backend/models/alert.py b/products/alerts/backend/models/alert.py
index d6206a1c35f9..73f36d3f0510 100644
--- a/products/alerts/backend/models/alert.py
+++ b/products/alerts/backend/models/alert.py
@@ -65,8 +65,8 @@ def derive_detector_event_fields(detector_config: dict | None) -> dict:
# TODO: Enable `@deprecated` once we move to Python 3.13
# @deprecated("AlertConfiguration should be used instead.")
class Alert(models.Model):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
- insight = models.ForeignKey("product_analytics.Insight", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
+ insight = models.ForeignKey("product_analytics.Insight", on_delete=models.CASCADE, related_name="+")
name = models.CharField(max_length=100)
target_value = models.TextField()
@@ -82,8 +82,8 @@ class Threshold(ModelActivityMixin, CreatedMetaFields, UUIDTModel):
object for other purposes.
"""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
- insight = models.ForeignKey("product_analytics.Insight", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
+ insight = models.ForeignKey("product_analytics.Insight", on_delete=models.CASCADE, related_name="+")
name = models.CharField(max_length=255, blank=True)
configuration = models.JSONField(default=dict)
diff --git a/products/analytics_platform/backend/migrations/0005_alter_preaggregationjob_team.py b/products/analytics_platform/backend/migrations/0005_alter_preaggregationjob_team.py
new file mode 100644
index 000000000000..2efc6404054b
--- /dev/null
+++ b/products/analytics_platform/backend/migrations/0005_alter_preaggregationjob_team.py
@@ -0,0 +1,24 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("analytics_platform", "0004_unique_pending_job_index"),
+ ("posthog", "1349_delete_persistedfolder_from_state"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="preaggregationjob",
+ name="team",
+ field=models.ForeignKey(
+ editable=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/analytics_platform/backend/migrations/max_migration.txt b/products/analytics_platform/backend/migrations/max_migration.txt
index bde4b80dd4ff..a74782786ee1 100644
--- a/products/analytics_platform/backend/migrations/max_migration.txt
+++ b/products/analytics_platform/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0004_unique_pending_job_index
+0005_alter_preaggregationjob_team
diff --git a/products/analytics_platform/backend/models/preaggregation_job.py b/products/analytics_platform/backend/models/preaggregation_job.py
index 288897c47f51..c6e74f01473b 100644
--- a/products/analytics_platform/backend/models/preaggregation_job.py
+++ b/products/analytics_platform/backend/models/preaggregation_job.py
@@ -10,7 +10,7 @@ class PreaggregationJob(CreatedMetaFields, UUIDModel):
STALE = "stale", "Stale"
FAILED = "failed", "Failed"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, editable=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, editable=False, related_name="+")
# Time range this job covers
time_range_start = models.DateTimeField()
diff --git a/products/annotations/backend/migrations/0002_alter_annotation_created_by_and_more.py b/products/annotations/backend/migrations/0002_alter_annotation_created_by_and_more.py
new file mode 100644
index 000000000000..abca4841c56e
--- /dev/null
+++ b/products/annotations/backend/migrations/0002_alter_annotation_created_by_and_more.py
@@ -0,0 +1,70 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("annotations", "0001_squash_2026_09_07_initial"),
+ ("dashboards", "0018_squash_2026_09_07_schema_addons"),
+ ("posthog", "1349_delete_persistedfolder_from_state"),
+ ("product_analytics", "0008_repair_insightviewed_null_unique_index"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="annotation",
+ 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="annotation",
+ name="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="annotation",
+ name="dashboard_item",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="product_analytics.insight",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="annotation",
+ name="organization",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.organization",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="annotation",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/annotations/backend/migrations/max_migration.txt b/products/annotations/backend/migrations/max_migration.txt
index 6903cd5e3dc2..2f9974494b21 100644
--- a/products/annotations/backend/migrations/max_migration.txt
+++ b/products/annotations/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_squash_2026_09_07_initial
+0002_alter_annotation_created_by_and_more
diff --git a/products/annotations/backend/models/annotation.py b/products/annotations/backend/models/annotation.py
index 3bf838b5bac5..bfd6f41590c4 100644
--- a/products/annotations/backend/models/annotation.py
+++ b/products/annotations/backend/models/annotation.py
@@ -23,11 +23,15 @@ class Annotation(ModelActivityMixin, models.Model):
content = models.CharField(max_length=8192, null=True, blank=True)
created_at = models.DateTimeField(default=timezone.now, null=True)
updated_at = models.DateTimeField(auto_now=True)
- dashboard_item = models.ForeignKey("product_analytics.Insight", on_delete=models.SET_NULL, null=True, blank=True)
- dashboard = models.ForeignKey("dashboards.Dashboard", on_delete=models.SET_NULL, null=True, blank=True)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
- organization = models.ForeignKey("posthog.Organization", on_delete=models.CASCADE, null=True)
- created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True)
+ dashboard_item = models.ForeignKey(
+ "product_analytics.Insight", on_delete=models.SET_NULL, null=True, blank=True, related_name="+"
+ )
+ dashboard = models.ForeignKey(
+ "dashboards.Dashboard", on_delete=models.SET_NULL, null=True, blank=True, related_name="+"
+ )
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
+ organization = models.ForeignKey("posthog.Organization", on_delete=models.CASCADE, null=True, related_name="+")
+ created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True, related_name="+")
scope = models.CharField(max_length=24, choices=Scope, default=Scope.INSIGHT)
# Optional emoji shown in place of the default badge when surfacing the annotation.
# Long enough to hold a single multi-codepoint grapheme (ZWJ sequences, skin-tone modifiers).
diff --git a/products/approvals/backend/migrations/0003_alter_approvalpolicy_organization_and_more.py b/products/approvals/backend/migrations/0003_alter_approvalpolicy_organization_and_more.py
new file mode 100644
index 000000000000..24d6e170099b
--- /dev/null
+++ b/products/approvals/backend/migrations/0003_alter_approvalpolicy_organization_and_more.py
@@ -0,0 +1,52 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("approvals", "0002_alter_changerequest_validation_status"),
+ ("posthog", "1349_delete_persistedfolder_from_state"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="approvalpolicy",
+ name="organization",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.organization",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="approvalpolicy",
+ name="team",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="changerequest",
+ name="organization",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.organization",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="changerequest",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/approvals/backend/migrations/max_migration.txt b/products/approvals/backend/migrations/max_migration.txt
index 5476a3a14938..de80a294a9c3 100644
--- a/products/approvals/backend/migrations/max_migration.txt
+++ b/products/approvals/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0002_alter_changerequest_validation_status
+0003_alter_approvalpolicy_organization_and_more
diff --git a/products/approvals/backend/models.py b/products/approvals/backend/models.py
index 5ba351ccdae2..200dc0f2812a 100644
--- a/products/approvals/backend/models.py
+++ b/products/approvals/backend/models.py
@@ -33,8 +33,8 @@ class ChangeRequest(UUIDModel, CreatedMetaFields, UpdatedMetaFields):
action_key = models.CharField(max_length=128)
action_version = models.IntegerField(default=1)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
- organization = models.ForeignKey("posthog.Organization", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
+ organization = models.ForeignKey("posthog.Organization", on_delete=models.CASCADE, related_name="+")
resource_type = models.CharField(max_length=64)
resource_id = models.CharField(max_length=128, null=True, blank=True)
@@ -146,16 +146,8 @@ class ApprovalPolicyManager(models.Manager):
class ApprovalPolicy(UUIDModel, CreatedMetaFields, UpdatedMetaFields):
"""Defines when an action requires approval and who can approve"""
- organization = models.ForeignKey(
- "posthog.Organization",
- on_delete=models.CASCADE,
- )
- team = models.ForeignKey(
- "posthog.Team",
- on_delete=models.CASCADE,
- null=True,
- blank=True,
- )
+ organization = models.ForeignKey("posthog.Organization", on_delete=models.CASCADE, related_name="+")
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, null=True, blank=True, related_name="+")
action_key = models.CharField(max_length=128)
diff --git a/products/batch_exports/backend/management/commands/check_batch_export_billing_limits.py b/products/batch_exports/backend/management/commands/check_batch_export_billing_limits.py
index d7dd2392d581..85c85f4e17cd 100644
--- a/products/batch_exports/backend/management/commands/check_batch_export_billing_limits.py
+++ b/products/batch_exports/backend/management/commands/check_batch_export_billing_limits.py
@@ -64,15 +64,16 @@ class Command(BaseCommand):
QuotaLimitingCaches.QUOTA_LIMITER_CACHE_KEY,
use_cache=False,
)
+ active_export_team_ids = BatchExport.objects.filter(deleted=False, paused=False).values_list(
+ "team_id", flat=True
+ )
+ non_billable_team_ids = BatchExport.objects.filter(destination__type__in=NON_BILLABLE_DESTINATIONS).values_list(
+ "team_id", flat=True
+ )
return list(
Team.objects.select_related("organization")
- .filter(
- api_token__in=limited_tokens,
- batchexport__deleted=False,
- batchexport__paused=False,
- )
- .exclude(batchexport__destination__type__in=NON_BILLABLE_DESTINATIONS)
- .distinct()
+ .filter(api_token__in=limited_tokens, id__in=active_export_team_ids)
+ .exclude(id__in=non_billable_team_ids)
)
def _report_team(self, team: Team, as_json: bool, checked: bool) -> None:
diff --git a/products/batch_exports/backend/migrations/0006_alter_batchexport_team_and_more.py b/products/batch_exports/backend/migrations/0006_alter_batchexport_team_and_more.py
new file mode 100644
index 000000000000..dca3f5c13dc1
--- /dev/null
+++ b/products/batch_exports/backend/migrations/0006_alter_batchexport_team_and_more.py
@@ -0,0 +1,67 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("batch_exports", "0005_add_batch_export_source"),
+ ("posthog", "1349_delete_persistedfolder_from_state"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="batchexport",
+ name="team",
+ field=models.ForeignKey(
+ help_text="The team this belongs to.",
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="batchexportdestination",
+ name="integration",
+ field=models.ForeignKey(
+ blank=True,
+ help_text="The integration for this destination.",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="posthog.integration",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="batchexportfiledownload",
+ name="team",
+ field=models.ForeignKey(
+ help_text="The team this belongs to.",
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="batchexportondemand",
+ name="team",
+ field=models.ForeignKey(
+ help_text="The team this belongs to.",
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="batchexportsource",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ help_text="The team this belongs to.",
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/batch_exports/backend/migrations/max_migration.txt b/products/batch_exports/backend/migrations/max_migration.txt
index 7a1fcb964e55..0843f31317d3 100644
--- a/products/batch_exports/backend/migrations/max_migration.txt
+++ b/products/batch_exports/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0005_add_batch_export_source
+0006_alter_batchexport_team_and_more
diff --git a/products/batch_exports/backend/models/batch_export.py b/products/batch_exports/backend/models/batch_export.py
index 3ed6162ab2e0..3096c98e5284 100644
--- a/products/batch_exports/backend/models/batch_export.py
+++ b/products/batch_exports/backend/models/batch_export.py
@@ -124,6 +124,7 @@ class BatchExportDestination(UUIDTModel):
help_text="The integration for this destination.",
null=True,
blank=True,
+ related_name="+",
)
@@ -148,6 +149,7 @@ class BatchExportSource(TeamScopedRootMixin, UUIDTModel):
on_delete=models.CASCADE,
db_constraint=False,
help_text="The team this belongs to.",
+ related_name="+",
)
hogql_query = models.TextField(
null=True,
@@ -320,7 +322,9 @@ class BatchExport(ModelActivityMixin, UUIDTModel):
SESSIONS = "sessions"
HOGQL = "hogql"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, help_text="The team this belongs to.")
+ team = models.ForeignKey(
+ "posthog.Team", on_delete=models.CASCADE, help_text="The team this belongs to.", related_name="+"
+ )
name = models.TextField(help_text="A human-readable name for this BatchExport.")
destination = models.ForeignKey(
"BatchExportDestination",
@@ -623,7 +627,9 @@ class BatchExportFileDownload(ModelActivityMixin, UUIDTModel):
models.Index(fields=["team", "key"], name="team_key_idx"),
]
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, help_text="The team this belongs to.")
+ team = models.ForeignKey(
+ "posthog.Team", on_delete=models.CASCADE, help_text="The team this belongs to.", related_name="+"
+ )
batch_export_run = models.ForeignKey(
"BatchExportRun",
on_delete=models.CASCADE,
@@ -684,7 +690,9 @@ class BatchExportOnDemand(TeamScopedRootMixin, ModelActivityMixin, UUIDTModel):
SESSIONS = "sessions"
HOGQL = "hogql"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, help_text="The team this belongs to.")
+ team = models.ForeignKey(
+ "posthog.Team", on_delete=models.CASCADE, help_text="The team this belongs to.", related_name="+"
+ )
destination = models.ForeignKey(
"BatchExportDestination",
on_delete=models.CASCADE,
diff --git a/products/canvas/backend/migrations/0019_alter_canvas_created_by_alter_canvas_team_and_more.py b/products/canvas/backend/migrations/0019_alter_canvas_created_by_alter_canvas_team_and_more.py
new file mode 100644
index 000000000000..2cb027ffdec0
--- /dev/null
+++ b/products/canvas/backend/migrations/0019_alter_canvas_created_by_alter_canvas_team_and_more.py
@@ -0,0 +1,112 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("canvas", "0018_remove_canvas_context"),
+ ("posthog", "1349_delete_persistedfolder_from_state"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="canvas",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="canvas",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="canvasbuild",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="canvashomepreference",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="canvashomepreference",
+ name="user",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="canvassourceversion",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="canvassourceversion",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="canvasstate",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="canvasstate",
+ name="user",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ]
diff --git a/products/canvas/backend/migrations/max_migration.txt b/products/canvas/backend/migrations/max_migration.txt
index c7d5a931c758..e52f6170e88b 100644
--- a/products/canvas/backend/migrations/max_migration.txt
+++ b/products/canvas/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0018_remove_canvas_context
+0019_alter_canvas_created_by_alter_canvas_team_and_more
diff --git a/products/canvas/backend/models.py b/products/canvas/backend/models.py
index 05a7c9f8b0e2..fff2de6e054e 100644
--- a/products/canvas/backend/models.py
+++ b/products/canvas/backend/models.py
@@ -39,7 +39,7 @@ class Canvas(TeamScopedRootMixin, UUIDModel):
# db_constraint=False: a real FK constraint to the hot posthog_team table
# takes a parent lock during migration; scoping is enforced app-side.
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ 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")
@@ -70,7 +70,7 @@ class Canvas(TeamScopedRootMixin, UUIDModel):
legacy_code = models.TextField(null=True, blank=True)
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
created_at = models.DateTimeField(default=timezone.now)
updated_at = models.DateTimeField(auto_now=True)
@@ -99,7 +99,7 @@ class CanvasSourceVersion(TeamScopedRootMixin, UUIDModel):
an existing version.
"""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
canvas = models.ForeignKey(Canvas, on_delete=models.CASCADE, related_name="source_versions")
parent_version = models.ForeignKey("self", on_delete=models.SET_NULL, null=True, blank=True, related_name="+")
@@ -132,7 +132,7 @@ class CanvasSourceVersion(TeamScopedRootMixin, UUIDModel):
draft = models.BooleanField(default=False)
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
created_at = models.DateTimeField(default=timezone.now)
@@ -156,7 +156,7 @@ class CanvasBuild(TeamScopedRootMixin, UUIDModel):
STATUS_FAILED = "failed"
ACTIVE_STATUSES = [STATUS_QUEUED, STATUS_BUILDING]
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
canvas = models.ForeignKey(Canvas, on_delete=models.CASCADE, related_name="builds")
source_version = models.ForeignKey(CanvasSourceVersion, on_delete=models.CASCADE, related_name="builds")
@@ -215,8 +215,8 @@ class CanvasHomePreference(TeamScopedRootMixin, UUIDModel):
home set — filter ``canvas__deleted=False`` — and re-provision on next open.
"""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
- user = models.ForeignKey("posthog.User", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
+ user = models.ForeignKey("posthog.User", on_delete=models.CASCADE, db_constraint=False, related_name="+")
canvas = models.ForeignKey(Canvas, on_delete=models.CASCADE, related_name="+")
created_at = models.DateTimeField(default=timezone.now)
@@ -242,11 +242,13 @@ class CanvasState(TeamScopedRootMixin, UUIDModel):
SCOPE_SHARED = "shared"
SCOPES = [SCOPE_USER, SCOPE_SHARED]
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
canvas = models.ForeignKey(Canvas, on_delete=models.CASCADE, related_name="state_entries")
scope = models.CharField(max_length=8)
# The owning viewer for user-scoped rows; always null for shared rows.
- user = models.ForeignKey("posthog.User", on_delete=models.CASCADE, null=True, blank=True, db_constraint=False)
+ user = models.ForeignKey(
+ "posthog.User", on_delete=models.CASCADE, null=True, blank=True, db_constraint=False, related_name="+"
+ )
key = models.CharField(max_length=200)
value = models.JSONField()
created_at = models.DateTimeField(default=timezone.now)
diff --git a/products/cohorts/backend/migrations/0014_alter_cohort_created_by_alter_cohort_people_and_more.py b/products/cohorts/backend/migrations/0014_alter_cohort_created_by_alter_cohort_people_and_more.py
new file mode 100644
index 000000000000..5143a750cf38
--- /dev/null
+++ b/products/cohorts/backend/migrations/0014_alter_cohort_created_by_alter_cohort_people_and_more.py
@@ -0,0 +1,41 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("cohorts", "0013_squash_2026_09_07_finalize_fks"),
+ ("posthog", "1349_delete_persistedfolder_from_state"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="cohort",
+ 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="cohort",
+ name="people",
+ field=models.ManyToManyField(related_name="+", through="cohorts.CohortPeople", to="posthog.person"),
+ ),
+ migrations.AlterField(
+ model_name="cohortcalculationhistory",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/cohorts/backend/migrations/max_migration.txt b/products/cohorts/backend/migrations/max_migration.txt
index 7346a6beab69..2609fd5433ba 100644
--- a/products/cohorts/backend/migrations/max_migration.txt
+++ b/products/cohorts/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0013_squash_2026_09_07_finalize_fks
+0014_alter_cohort_created_by_alter_cohort_people_and_more
diff --git a/products/cohorts/backend/models/calculation_history.py b/products/cohorts/backend/models/calculation_history.py
index a30fc44ce3d3..e4e7da23cceb 100644
--- a/products/cohorts/backend/models/calculation_history.py
+++ b/products/cohorts/backend/models/calculation_history.py
@@ -11,7 +11,7 @@ class CohortCalculationHistory(RootTeamMixin, UUIDModel):
Track cohort calculation statistics for performance monitoring and debugging.
"""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
cohort = models.ForeignKey("cohorts.Cohort", on_delete=models.CASCADE)
# Calculation metadata
diff --git a/products/cohorts/backend/models/cohort.py b/products/cohorts/backend/models/cohort.py
index b6fc7761aae0..3a87bcc188f8 100644
--- a/products/cohorts/backend/models/cohort.py
+++ b/products/cohorts/backend/models/cohort.py
@@ -184,6 +184,8 @@ def is_cohort_recalculation_only_save(kwargs: dict) -> bool:
class Cohort(FileSystemSyncMixin, RootTeamMixin, models.Model):
name = models.CharField(max_length=400, null=True, blank=True)
description = models.CharField(max_length=1000, blank=True)
+ # Not sealed: the feature flag list endpoint prefetches team__cohort_set
+ # into available_cohorts.
team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
deleted = models.BooleanField(default=False)
filters = models.JSONField(
@@ -250,12 +252,12 @@ class Cohort(FileSystemSyncMixin, RootTeamMixin, models.Model):
}""",
)
query = models.JSONField(null=True, blank=True)
- people = models.ManyToManyField("posthog.Person", through="CohortPeople") # type: models.ManyToManyField
+ people = models.ManyToManyField("posthog.Person", through="CohortPeople", related_name="+") # type: models.ManyToManyField
version = models.IntegerField(blank=True, null=True)
pending_version = models.IntegerField(blank=True, null=True)
count = models.IntegerField(blank=True, null=True)
- created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, blank=True, null=True)
+ created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, blank=True, null=True, related_name="+")
created_at = models.DateTimeField(default=timezone.now, blank=True, null=True)
is_calculating = models.BooleanField(default=False)
@@ -1389,7 +1391,7 @@ def get_or_create_internal_test_users_cohort(
class CohortPeople(models.Model):
id = models.BigAutoField(primary_key=True)
cohort = models.ForeignKey("Cohort", on_delete=models.DO_NOTHING, db_constraint=False)
- person = models.ForeignKey("posthog.Person", on_delete=models.DO_NOTHING, db_constraint=False)
+ person = models.ForeignKey("posthog.Person", on_delete=models.DO_NOTHING, db_constraint=False, related_name="+")
version = models.IntegerField(blank=True, null=True)
class Meta:
diff --git a/products/conversations/backend/migrations/0068_alter_emailchannelsetup_team_and_more.py b/products/conversations/backend/migrations/0068_alter_emailchannelsetup_team_and_more.py
new file mode 100644
index 000000000000..03cebd1609c2
--- /dev/null
+++ b/products/conversations/backend/migrations/0068_alter_emailchannelsetup_team_and_more.py
@@ -0,0 +1,200 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("conversations", "0067_conversationinboundevent"),
+ ("ee", "0063_scim_provisioned_user_config_set_null"),
+ ("posthog", "1349_delete_persistedfolder_from_state"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="emailchannelsetup",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="emailmessagemapping",
+ name="comment",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.comment",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="emailmessagemapping",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="emailoutboxmessage",
+ name="comment",
+ field=models.OneToOneField(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.comment",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="emailoutboxmessage",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="emailthread",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="emailthreadaccountlink",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="emailthreadmessage",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="emailthreadparticipant",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="githubcommentmapping",
+ name="comment",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.comment",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="githubcommentmapping",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="teamconversationsteamschannelsync",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="ticket",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="ticketassignment",
+ name="role",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="ee.role",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="ticketassignment",
+ name="user",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="ticketview",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="ticketviewfavorite",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="ticketviewfavorite",
+ name="user",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="zendeskimportjob",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/conversations/backend/migrations/max_migration.txt b/products/conversations/backend/migrations/max_migration.txt
index ef37a6fc064c..05b24850e0b7 100644
--- a/products/conversations/backend/migrations/max_migration.txt
+++ b/products/conversations/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0067_conversationinboundevent
+0068_alter_emailchannelsetup_team_and_more
diff --git a/products/conversations/backend/models/assignment.py b/products/conversations/backend/models/assignment.py
index 1e0969bda4d0..522545ac391a 100644
--- a/products/conversations/backend/models/assignment.py
+++ b/products/conversations/backend/models/assignment.py
@@ -5,8 +5,8 @@ from posthog.models.utils import UUIDTModel
class TicketAssignment(UUIDTModel):
ticket = models.OneToOneField("conversations.Ticket", on_delete=models.CASCADE, related_name="assignment")
- user = models.ForeignKey("posthog.User", null=True, on_delete=models.CASCADE)
- role = models.ForeignKey("ee.Role", null=True, on_delete=models.CASCADE)
+ user = models.ForeignKey("posthog.User", null=True, on_delete=models.CASCADE, related_name="+")
+ role = models.ForeignKey("ee.Role", null=True, on_delete=models.CASCADE, related_name="+")
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
diff --git a/products/conversations/backend/models/email_channel_setup.py b/products/conversations/backend/models/email_channel_setup.py
index c980644e07ab..10eb40c81b09 100644
--- a/products/conversations/backend/models/email_channel_setup.py
+++ b/products/conversations/backend/models/email_channel_setup.py
@@ -10,7 +10,7 @@ class EmailChannelSetupProvider(models.TextChoices):
class EmailChannelSetup(TeamScopedRootMixin, UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
channel = models.OneToOneField(
"conversations.EmailChannel",
on_delete=models.CASCADE,
diff --git a/products/conversations/backend/models/email_message_mapping.py b/products/conversations/backend/models/email_message_mapping.py
index 4c4c39750bea..b3d599e3385d 100644
--- a/products/conversations/backend/models/email_message_mapping.py
+++ b/products/conversations/backend/models/email_message_mapping.py
@@ -7,9 +7,9 @@ from .ticket import Ticket
class EmailMessageMapping(UUIDModel):
message_id = models.CharField(max_length=255, db_index=True)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
ticket = models.ForeignKey(Ticket, on_delete=models.CASCADE)
- comment = models.ForeignKey("posthog.Comment", on_delete=models.CASCADE)
+ comment = models.ForeignKey("posthog.Comment", on_delete=models.CASCADE, related_name="+")
full_body_plain = models.TextField(blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True)
diff --git a/products/conversations/backend/models/email_outbox_message.py b/products/conversations/backend/models/email_outbox_message.py
index 72079713eb2b..f0c5f0aea0bc 100644
--- a/products/conversations/backend/models/email_outbox_message.py
+++ b/products/conversations/backend/models/email_outbox_message.py
@@ -21,10 +21,10 @@ class EmailOutboxMessage(UUIDModel):
SENT = "sent", "Sent"
FAILED_PERMANENT = "failed_permanent", "Failed (permanent)"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
ticket = models.ForeignKey(Ticket, on_delete=models.CASCADE)
# One outbox row per agent reply comment — the idempotency key across retries.
- comment = models.OneToOneField("posthog.Comment", on_delete=models.CASCADE)
+ comment = models.OneToOneField("posthog.Comment", on_delete=models.CASCADE, related_name="+")
# Stable Message-ID for the outbound email, generated once and reused on every
# attempt so threading headers and dedup stay consistent across resends.
diff --git a/products/conversations/backend/models/email_thread.py b/products/conversations/backend/models/email_thread.py
index 56d6a5bc84c7..dbfa193405ab 100644
--- a/products/conversations/backend/models/email_thread.py
+++ b/products/conversations/backend/models/email_thread.py
@@ -29,7 +29,7 @@ class EmailThreadParticipantKind(models.TextChoices):
class EmailThread(TeamScopedRootMixin, UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
canonical_thread_key = models.CharField(max_length=998)
subject = models.TextField(default="", blank=True)
first_message_at = models.DateTimeField(null=True, blank=True)
@@ -53,7 +53,7 @@ class EmailThread(TeamScopedRootMixin, UUIDModel):
class EmailThreadAccountLink(TeamScopedRootMixin, UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
thread = models.ForeignKey("conversations.EmailThread", on_delete=models.CASCADE, related_name="account_links")
account_id = models.CharField(max_length=64)
account_external_id = models.CharField(max_length=400, null=True, blank=True)
@@ -75,7 +75,7 @@ class EmailThreadAccountLink(TeamScopedRootMixin, UUIDModel):
class EmailThreadMessage(TeamScopedRootMixin, UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
thread = models.ForeignKey("conversations.EmailThread", on_delete=models.CASCADE, related_name="messages")
comment = models.OneToOneField(
"posthog.Comment",
@@ -117,7 +117,7 @@ class EmailThreadMessage(TeamScopedRootMixin, UUIDModel):
class EmailThreadParticipant(TeamScopedRootMixin, UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
thread = models.ForeignKey("conversations.EmailThread", on_delete=models.CASCADE, related_name="participants")
email = models.CharField(max_length=400)
display_name = models.CharField(max_length=400, default="", blank=True)
diff --git a/products/conversations/backend/models/github_comment_mapping.py b/products/conversations/backend/models/github_comment_mapping.py
index e550521e1a3e..becd9b7a674f 100644
--- a/products/conversations/backend/models/github_comment_mapping.py
+++ b/products/conversations/backend/models/github_comment_mapping.py
@@ -7,9 +7,9 @@ from .ticket import Ticket
class GithubCommentMapping(UUIDModel):
github_comment_id = models.BigIntegerField(db_index=True)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
ticket = models.ForeignKey(Ticket, on_delete=models.CASCADE)
- comment = models.ForeignKey("posthog.Comment", on_delete=models.CASCADE, null=True, blank=True)
+ comment = models.ForeignKey("posthog.Comment", on_delete=models.CASCADE, null=True, blank=True, related_name="+")
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
diff --git a/products/conversations/backend/models/team_conversations_teams_channel_sync.py b/products/conversations/backend/models/team_conversations_teams_channel_sync.py
index 71b3e39f152c..062a5ac44514 100644
--- a/products/conversations/backend/models/team_conversations_teams_channel_sync.py
+++ b/products/conversations/backend/models/team_conversations_teams_channel_sync.py
@@ -16,7 +16,7 @@ class TeamConversationsTeamsChannelSync(TeamScopedRootMixin, UUIDModel):
writes don't contend with the settings blob and survive channel add/remove.
"""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
teams_team_id = models.CharField(max_length=255)
channel_id = models.CharField(max_length=255)
diff --git a/products/conversations/backend/models/ticket.py b/products/conversations/backend/models/ticket.py
index a0533c76c607..af29f63b8133 100644
--- a/products/conversations/backend/models/ticket.py
+++ b/products/conversations/backend/models/ticket.py
@@ -50,7 +50,7 @@ class Ticket(UUIDTModel):
# Dynamic attribute set by TicketViewSet._attach_persons_to_tickets for serialization
person: "Person | None"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
ticket_number = models.PositiveIntegerField()
channel_source = models.CharField(max_length=20, choices=Channel, default=Channel.WIDGET)
channel_detail = models.CharField(max_length=30, choices=ChannelDetail, null=True, blank=True)
diff --git a/products/conversations/backend/models/ticket_view.py b/products/conversations/backend/models/ticket_view.py
index 020c1c238ece..0efc10058fac 100644
--- a/products/conversations/backend/models/ticket_view.py
+++ b/products/conversations/backend/models/ticket_view.py
@@ -7,7 +7,7 @@ from posthog.utils import generate_short_id
class TicketView(CreatedMetaFields, UpdatedMetaFields, UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
short_id = models.CharField(max_length=12, blank=True, default=generate_short_id)
name = models.CharField(max_length=400)
filters = models.JSONField(default=dict)
diff --git a/products/conversations/backend/models/ticket_view_favorite.py b/products/conversations/backend/models/ticket_view_favorite.py
index ba2b9f86a41c..39608bc4be76 100644
--- a/products/conversations/backend/models/ticket_view_favorite.py
+++ b/products/conversations/backend/models/ticket_view_favorite.py
@@ -12,9 +12,9 @@ from .ticket_view import TicketView
class TicketViewFavorite(TeamScopedRootMixin, UUIDModel):
# db_constraint=False on the hot-table FKs (team, user) so CreateModel takes no lock
# on posthog_team / posthog_user; app-level enforcement is enough here.
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
ticket_view = models.ForeignKey(TicketView, on_delete=models.CASCADE, related_name="favorites")
- user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, db_constraint=False)
+ user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
diff --git a/products/conversations/backend/models/zendesk_import_job.py b/products/conversations/backend/models/zendesk_import_job.py
index 05dc3401aebb..3c720a8f1f1a 100644
--- a/products/conversations/backend/models/zendesk_import_job.py
+++ b/products/conversations/backend/models/zendesk_import_job.py
@@ -14,7 +14,7 @@ class ZendeskImportJob(TeamScopedRootMixin, UUIDModel):
# db_constraint=False: a real FK constraint would take SHARE ROW EXCLUSIVE on the
# hot posthog_team table on CreateModel. App-level enforcement is enough here.
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
status = models.CharField(max_length=32, choices=Status, default=Status.PENDING)
total_tickets = models.BigIntegerField(default=0)
diff --git a/products/customer_analytics/backend/migrations/0052_alter_account_team_alter_accountchannelsummary_team_and_more.py b/products/customer_analytics/backend/migrations/0052_alter_account_team_alter_accountchannelsummary_team_and_more.py
new file mode 100644
index 000000000000..5df73fd2e728
--- /dev/null
+++ b/products/customer_analytics/backend/migrations/0052_alter_account_team_alter_accountchannelsummary_team_and_more.py
@@ -0,0 +1,348 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("customer_analytics", "0051_squash_2026_09_07_schema_addons"),
+ ("posthog", "1349_delete_persistedfolder_from_state"),
+ ("product_analytics", "0008_repair_insightviewed_null_unique_index"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="account",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="accountchannelsummary",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="accountrelationship",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="accountrelationship",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="accountrelationshipdefinition",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="accountrelationshipdefinition",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="accounttrackrulerun",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="accounttrackrulerun",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="announcement",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="announcement",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="announcementdelivery",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="customerjourney",
+ name="insight",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="product_analytics.insight",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="customerjourney",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="customerprofileconfig",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="custompropertydefinition",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="custompropertysource",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="custompropertysource",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="custompropertysyncrun",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="custompropertysyncrun",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="custompropertyvalue",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="custompropertyvalue",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="eventstream",
+ name="created_by",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="eventstreammember",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="eventstreammember",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="featurerequest",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="featurerequestaccountlink",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="featurerequestevidence",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="featurerequesthistory",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="featurerequestproductarea",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="featurerequestproductarealink",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="meeting",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="meetingparticipant",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/customer_analytics/backend/migrations/max_migration.txt b/products/customer_analytics/backend/migrations/max_migration.txt
index b236708a9e5c..f8a0535aaf6c 100644
--- a/products/customer_analytics/backend/migrations/max_migration.txt
+++ b/products/customer_analytics/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0051_squash_2026_09_07_schema_addons
+0052_alter_account_team_alter_accountchannelsummary_team_and_more
diff --git a/products/customer_analytics/backend/models/account.py b/products/customer_analytics/backend/models/account.py
index c484232f8153..33ada914c470 100644
--- a/products/customer_analytics/backend/models/account.py
+++ b/products/customer_analytics/backend/models/account.py
@@ -72,7 +72,7 @@ class AccountProperties(BaseModel):
class Account(TeamScopedRootMixin, UUIDModel, CreatedMetaFields, UpdatedMetaFields):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
external_id = models.CharField(max_length=400, null=True, blank=True)
name = models.CharField(max_length=400)
diff --git a/products/customer_analytics/backend/models/account_channel_summary.py b/products/customer_analytics/backend/models/account_channel_summary.py
index 6ba93bdf03fc..e352e66d9139 100644
--- a/products/customer_analytics/backend/models/account_channel_summary.py
+++ b/products/customer_analytics/backend/models/account_channel_summary.py
@@ -22,7 +22,7 @@ class AccountChannelSummary(TeamScopedRootMixin, UUIDModel):
all_teams = models.Manager() # noqa: DJ012
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
account = models.ForeignKey(
"customer_analytics.Account", on_delete=models.CASCADE, related_name="channel_summaries"
)
diff --git a/products/customer_analytics/backend/models/account_track_rule_run.py b/products/customer_analytics/backend/models/account_track_rule_run.py
index b42e3e48a545..816ecbb94f84 100644
--- a/products/customer_analytics/backend/models/account_track_rule_run.py
+++ b/products/customer_analytics/backend/models/account_track_rule_run.py
@@ -18,9 +18,9 @@ class AccountTrackRuleRunStatus(models.TextChoices):
class AccountTrackRuleRun(TeamScopedRootMixin, UUIDModel, CreatedMetaFields):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
config_version = models.PositiveIntegerField()
diff --git a/products/customer_analytics/backend/models/announcement.py b/products/customer_analytics/backend/models/announcement.py
index 303cc0de8bab..92282d2ab874 100644
--- a/products/customer_analytics/backend/models/announcement.py
+++ b/products/customer_analytics/backend/models/announcement.py
@@ -17,9 +17,9 @@ class Announcement(TeamScopedRootMixin, UUIDModel, CreatedMetaFields, UpdatedMet
all_teams = models.Manager() # noqa: DJ012
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
short_id = models.CharField(max_length=12, blank=True, default=generate_short_id)
diff --git a/products/customer_analytics/backend/models/announcement_delivery.py b/products/customer_analytics/backend/models/announcement_delivery.py
index 0a0a27dee481..89e2dcaf125c 100644
--- a/products/customer_analytics/backend/models/announcement_delivery.py
+++ b/products/customer_analytics/backend/models/announcement_delivery.py
@@ -16,7 +16,7 @@ class AnnouncementDelivery(TeamScopedRootMixin, UUIDModel):
all_teams = models.Manager() # noqa: DJ012
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
announcement = models.ForeignKey(Announcement, on_delete=models.CASCADE, related_name="deliveries")
slack_channel_id = models.CharField(max_length=64)
slack_channel_name = models.CharField(max_length=255, blank=True, default="")
diff --git a/products/customer_analytics/backend/models/custom_property_definition.py b/products/customer_analytics/backend/models/custom_property_definition.py
index 51285349c4da..155aa366105a 100644
--- a/products/customer_analytics/backend/models/custom_property_definition.py
+++ b/products/customer_analytics/backend/models/custom_property_definition.py
@@ -56,7 +56,7 @@ CANONICAL_DISPLAY_TYPE_BY_NAME: dict[str, DisplayType] = {
class CustomPropertyDefinition(TeamScopedRootMixin, UUIDModel, CreatedMetaFields, UpdatedMetaFields):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
target_type = models.CharField(
choices=[(t.value, t.value) for t in TargetType],
diff --git a/products/customer_analytics/backend/models/custom_property_source.py b/products/customer_analytics/backend/models/custom_property_source.py
index 8319a45e1eea..96db632b5bb4 100644
--- a/products/customer_analytics/backend/models/custom_property_source.py
+++ b/products/customer_analytics/backend/models/custom_property_source.py
@@ -5,9 +5,9 @@ from posthog.models.utils import CreatedMetaFields, UpdatedMetaFields, UUIDModel
class CustomPropertySource(TeamScopedRootMixin, UUIDModel, CreatedMetaFields, UpdatedMetaFields):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
definition = models.OneToOneField(
diff --git a/products/customer_analytics/backend/models/custom_property_sync_run.py b/products/customer_analytics/backend/models/custom_property_sync_run.py
index 98d8ff236180..196b82c4a498 100644
--- a/products/customer_analytics/backend/models/custom_property_sync_run.py
+++ b/products/customer_analytics/backend/models/custom_property_sync_run.py
@@ -38,9 +38,9 @@ class SyncPhase(models.TextChoices):
class CustomPropertySyncRun(TeamScopedRootMixin, UUIDModel, CreatedMetaFields):
"""One warehouse sync run for a single custom property source."""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
source = models.ForeignKey(
diff --git a/products/customer_analytics/backend/models/custom_property_value.py b/products/customer_analytics/backend/models/custom_property_value.py
index 488fdec9cc8f..7029b8c12f0f 100644
--- a/products/customer_analytics/backend/models/custom_property_value.py
+++ b/products/customer_analytics/backend/models/custom_property_value.py
@@ -10,9 +10,9 @@ ACTIVE_VALUE_CONSTRAINT_NAME = "unique_active_custom_property_value"
class CustomPropertyValue(TeamScopedRootMixin, UUIDModel, CreatedMetaFields):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
definition = models.ForeignKey(
"customer_analytics.CustomPropertyDefinition", on_delete=models.CASCADE, related_name="values"
diff --git a/products/customer_analytics/backend/models/customer_journey.py b/products/customer_analytics/backend/models/customer_journey.py
index 2b409fc1da14..0424d0407810 100644
--- a/products/customer_analytics/backend/models/customer_journey.py
+++ b/products/customer_analytics/backend/models/customer_journey.py
@@ -4,8 +4,8 @@ from posthog.models.utils import CreatedMetaFields, UpdatedMetaFields, UUIDModel
class CustomerJourney(UUIDModel, CreatedMetaFields, UpdatedMetaFields):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
- insight = models.ForeignKey("product_analytics.Insight", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
+ insight = models.ForeignKey("product_analytics.Insight", on_delete=models.CASCADE, related_name="+")
name = models.CharField(max_length=400)
description = models.TextField(null=True, blank=True)
diff --git a/products/customer_analytics/backend/models/customer_profile_config.py b/products/customer_analytics/backend/models/customer_profile_config.py
index 02abb03165b4..66fc559bb6a3 100644
--- a/products/customer_analytics/backend/models/customer_profile_config.py
+++ b/products/customer_analytics/backend/models/customer_profile_config.py
@@ -13,7 +13,7 @@ class CustomerProfileConfig(UUIDModel, CreatedMetaFields, UpdatedMetaFields):
GROUP_3 = "group_3", "Group 3"
GROUP_4 = "group_4", "Group 4"
- team = models.ForeignKey(Team, on_delete=models.CASCADE)
+ team = models.ForeignKey(Team, on_delete=models.CASCADE, related_name="+")
content = models.JSONField(default=dict)
sidebar = models.JSONField(default=dict)
scope = models.CharField(max_length=255, choices=Scope)
diff --git a/products/customer_analytics/backend/models/event_stream.py b/products/customer_analytics/backend/models/event_stream.py
index 7e543caa345c..60d7eab7a371 100644
--- a/products/customer_analytics/backend/models/event_stream.py
+++ b/products/customer_analytics/backend/models/event_stream.py
@@ -19,7 +19,7 @@ class EventStream(TeamScopedRootMixin, UUIDModel, CreatedMetaFields, UpdatedMeta
db_constraint=False,
related_name="+",
)
- created_by = models.ForeignKey("posthog.User", on_delete=models.CASCADE, db_constraint=False)
+ created_by = models.ForeignKey("posthog.User", on_delete=models.CASCADE, db_constraint=False, related_name="+")
enabled = models.BooleanField(default=False)
event_names = models.JSONField(default=list)
@@ -41,9 +41,9 @@ class EventStream(TeamScopedRootMixin, UUIDModel, CreatedMetaFields, UpdatedMeta
class EventStreamMember(TeamScopedRootMixin, UUIDModel, CreatedMetaFields):
"""An account included in the team's event stream."""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
stream = models.ForeignKey(EventStream, on_delete=models.CASCADE, related_name="members")
diff --git a/products/customer_analytics/backend/models/feature_request.py b/products/customer_analytics/backend/models/feature_request.py
index 0c4126f29d56..8a65c35ed25a 100644
--- a/products/customer_analytics/backend/models/feature_request.py
+++ b/products/customer_analytics/backend/models/feature_request.py
@@ -25,7 +25,7 @@ class FeatureRequestHistorySource(models.TextChoices):
class FeatureRequestProductArea(TeamScopedRootMixin, UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
name = models.CharField(max_length=200)
display_order = models.PositiveIntegerField(default=0)
is_active = models.BooleanField(default=True)
@@ -46,7 +46,7 @@ class FeatureRequestProductArea(TeamScopedRootMixin, UUIDModel):
class FeatureRequest(TeamScopedRootMixin, UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
title = models.CharField(max_length=400)
description = models.TextField(blank=True, default="")
status = models.CharField(
@@ -81,7 +81,7 @@ class FeatureRequest(TeamScopedRootMixin, UUIDModel):
class FeatureRequestHistory(TeamScopedRootMixin, UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
feature_request = models.ForeignKey(
FeatureRequest,
on_delete=models.CASCADE,
@@ -109,7 +109,7 @@ class FeatureRequestHistory(TeamScopedRootMixin, UUIDModel):
class FeatureRequestAccountLink(TeamScopedRootMixin, UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
feature_request = models.ForeignKey(
FeatureRequest,
on_delete=models.CASCADE,
@@ -143,7 +143,7 @@ class FeatureRequestAccountLink(TeamScopedRootMixin, UUIDModel):
class FeatureRequestEvidence(TeamScopedRootMixin, UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
account_link = models.ForeignKey(
FeatureRequestAccountLink,
on_delete=models.CASCADE,
@@ -181,7 +181,7 @@ class FeatureRequestEvidence(TeamScopedRootMixin, UUIDModel):
class FeatureRequestProductAreaLink(TeamScopedRootMixin, UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
feature_request = models.ForeignKey(
FeatureRequest,
on_delete=models.CASCADE,
diff --git a/products/customer_analytics/backend/models/meeting.py b/products/customer_analytics/backend/models/meeting.py
index 06513577402f..daab6df330c3 100644
--- a/products/customer_analytics/backend/models/meeting.py
+++ b/products/customer_analytics/backend/models/meeting.py
@@ -27,7 +27,7 @@ class Meeting(TeamScopedRootMixin, UUIDModel):
a single instance is rescheduled, unlike the start time itself.
"""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
account = models.ForeignKey(
"customer_analytics.Account", on_delete=models.SET_NULL, null=True, blank=True, related_name="meetings"
)
@@ -60,7 +60,7 @@ class Meeting(TeamScopedRootMixin, UUIDModel):
class MeetingParticipant(TeamScopedRootMixin, UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
meeting = models.ForeignKey("customer_analytics.Meeting", on_delete=models.CASCADE, related_name="participants")
email = models.CharField(max_length=400)
diff --git a/products/customer_analytics/backend/models/relationship.py b/products/customer_analytics/backend/models/relationship.py
index 4a9e2c571bd3..66b771fa6cc2 100644
--- a/products/customer_analytics/backend/models/relationship.py
+++ b/products/customer_analytics/backend/models/relationship.py
@@ -7,9 +7,9 @@ from posthog.models.utils import CreatedMetaFields, UpdatedMetaFields, UUIDModel
class AccountRelationshipDefinition(TeamScopedRootMixin, UUIDModel, CreatedMetaFields, UpdatedMetaFields):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
name = models.CharField(max_length=400)
@@ -33,9 +33,9 @@ class AccountRelationshipDefinition(TeamScopedRootMixin, UUIDModel, CreatedMetaF
class AccountRelationship(TeamScopedRootMixin, UUIDModel, CreatedMetaFields):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
definition = models.ForeignKey(
"customer_analytics.AccountRelationshipDefinition", on_delete=models.CASCADE, related_name="relationships"
diff --git a/products/dashboards/backend/migrations/0019_alter_buttontile_created_by_alter_buttontile_team_and_more.py b/products/dashboards/backend/migrations/0019_alter_buttontile_created_by_alter_buttontile_team_and_more.py
new file mode 100644
index 000000000000..9fc92b2c5942
--- /dev/null
+++ b/products/dashboards/backend/migrations/0019_alter_buttontile_created_by_alter_buttontile_team_and_more.py
@@ -0,0 +1,109 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("dashboards", "0018_squash_2026_09_07_schema_addons"),
+ ("posthog", "1349_delete_persistedfolder_from_state"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="buttontile",
+ 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="buttontile",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="dashboard",
+ 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="dashboard",
+ name="data_color_theme",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="posthog.datacolortheme",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="dashboardtemplate",
+ 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="dashboardtemplate",
+ name="team",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="dashboardtile",
+ name="team",
+ field=models.ForeignKey(
+ db_index=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="dashboardwidget",
+ 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="dashboardwidget",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/dashboards/backend/migrations/max_migration.txt b/products/dashboards/backend/migrations/max_migration.txt
index c3ea6016b9a1..15ce2c720352 100644
--- a/products/dashboards/backend/migrations/max_migration.txt
+++ b/products/dashboards/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0018_squash_2026_09_07_schema_addons
+0019_alter_buttontile_created_by_alter_buttontile_team_and_more
diff --git a/products/dashboards/backend/models/dashboard.py b/products/dashboards/backend/models/dashboard.py
index aa9664e85b47..538cefc91640 100644
--- a/products/dashboards/backend/models/dashboard.py
+++ b/products/dashboards/backend/models/dashboard.py
@@ -66,7 +66,7 @@ class Dashboard(FileSystemSyncMixin, ModelActivityMixin, RootTeamMixin, models.M
team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
pinned = models.BooleanField(default=False)
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)
last_accessed_at = models.DateTimeField(blank=True, null=True)
last_refresh = models.DateTimeField(blank=True, null=True)
@@ -74,10 +74,7 @@ class Dashboard(FileSystemSyncMixin, ModelActivityMixin, RootTeamMixin, models.M
variables = models.JSONField(default=dict, null=True, blank=True)
breakdown_colors = models.JSONField(default=list, null=True, blank=True)
data_color_theme = models.ForeignKey(
- "posthog.DataColorTheme",
- on_delete=models.SET_NULL,
- null=True,
- blank=True,
+ "posthog.DataColorTheme", on_delete=models.SET_NULL, null=True, blank=True, related_name="+"
)
creation_mode = models.CharField(max_length=16, default="default", choices=CreationMode)
restriction_level = models.PositiveSmallIntegerField(
diff --git a/products/dashboards/backend/models/dashboard_templates.py b/products/dashboards/backend/models/dashboard_templates.py
index 5437e796d594..6444fcc7335c 100644
--- a/products/dashboards/backend/models/dashboard_templates.py
+++ b/products/dashboards/backend/models/dashboard_templates.py
@@ -22,7 +22,7 @@ class DashboardTemplate(UUIDTModel, RootTeamMixin):
GLOBAL = "global", "Global"
FEATURE_FLAG = "feature_flag", "Feature Flag"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, null=True)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, null=True, related_name="+")
template_name = models.CharField(max_length=400, null=True, blank=True)
dashboard_description = models.CharField(max_length=400, null=True, blank=True)
dashboard_filters = models.JSONField(null=True, blank=True)
@@ -30,7 +30,7 @@ class DashboardTemplate(UUIDTModel, RootTeamMixin):
variables = models.JSONField(null=True, blank=True)
tags: ArrayField = ArrayField(models.CharField(max_length=255), blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True, blank=True, null=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(blank=True, null=True)
image_url = models.CharField(max_length=8201, null=True, blank=True)
scope = models.CharField(max_length=24, choices=Scope, null=True, blank=True)
diff --git a/products/dashboards/backend/models/dashboard_tile.py b/products/dashboards/backend/models/dashboard_tile.py
index 7686e1b63e8c..bbad558b2b5d 100644
--- a/products/dashboards/backend/models/dashboard_tile.py
+++ b/products/dashboards/backend/models/dashboard_tile.py
@@ -35,7 +35,7 @@ class ButtonTile(UUIDModel):
max_length=10, choices=[("primary", "Primary"), ("secondary", "Secondary")], default="primary"
)
- 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="+")
last_modified_at = models.DateTimeField(default=timezone.now)
last_modified_by = models.ForeignKey(
"posthog.User",
@@ -45,7 +45,7 @@ class ButtonTile(UUIDModel):
related_name="modified_button_tiles",
)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
class Meta:
db_table = "posthog_buttontile"
@@ -90,7 +90,7 @@ class DashboardTile(models.Model):
# Auto-populated in save() when omitted. The index is created concurrently
# outside Django state (migration 0004) and not declared here, so db_index=False
# keeps state and DB in sync.
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_index=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_index=False, related_name="+")
# Tile layout and style
layouts = models.JSONField(default=dict)
diff --git a/products/dashboards/backend/models/dashboard_widget.py b/products/dashboards/backend/models/dashboard_widget.py
index 80337eca8095..9d48ab4b5148 100644
--- a/products/dashboards/backend/models/dashboard_widget.py
+++ b/products/dashboards/backend/models/dashboard_widget.py
@@ -12,7 +12,7 @@ class DashboardWidget(ModelActivityMixin, TeamScopedRootMixin, UUIDModel):
description = models.TextField(blank=True)
config = models.JSONField(default=dict)
- 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="+")
last_modified_at = models.DateTimeField(default=timezone.now)
last_modified_by = models.ForeignKey(
"posthog.User",
@@ -22,7 +22,7 @@ class DashboardWidget(ModelActivityMixin, TeamScopedRootMixin, UUIDModel):
related_name="modified_dashboard_widgets",
)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
all_teams = models.Manager() # noqa: DJ012
diff --git a/products/data_catalog/backend/migrations/0007_alter_metric_team_and_more.py b/products/data_catalog/backend/migrations/0007_alter_metric_team_and_more.py
new file mode 100644
index 000000000000..1422e5bf4e9b
--- /dev/null
+++ b/products/data_catalog/backend/migrations/0007_alter_metric_team_and_more.py
@@ -0,0 +1,70 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("data_catalog", "0006_metric_name_partial_unique"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="metric",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="relationshipproposal",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="relationshipproposal",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="tablecertification",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="tablecertification",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/data_catalog/backend/migrations/max_migration.txt b/products/data_catalog/backend/migrations/max_migration.txt
index fe00c70b45e0..42ef4c67fbbf 100644
--- a/products/data_catalog/backend/migrations/max_migration.txt
+++ b/products/data_catalog/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0006_metric_name_partial_unique
+0007_alter_metric_team_and_more
diff --git a/products/data_catalog/backend/models/certification.py b/products/data_catalog/backend/models/certification.py
index b32ed480c0ce..e5cf90b7644b 100644
--- a/products/data_catalog/backend/models/certification.py
+++ b/products/data_catalog/backend/models/certification.py
@@ -16,13 +16,9 @@ class TableCertification(CreatedMetaFields, UpdatedMetaFields, UUIDModel):
objects = EnvironmentScopedManager()
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User",
- on_delete=models.SET_NULL,
- null=True,
- blank=True,
- db_constraint=False,
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
table = models.ForeignKey(
"warehouse_sources.DataWarehouseTable",
diff --git a/products/data_catalog/backend/models/metric.py b/products/data_catalog/backend/models/metric.py
index ba724e1a5ab4..9f8472b86aa4 100644
--- a/products/data_catalog/backend/models/metric.py
+++ b/products/data_catalog/backend/models/metric.py
@@ -35,7 +35,7 @@ class Metric(
# db_constraint=False on FKs to hot tables (posthog_team, posthog_user): a real FK constraint
# takes SHARE ROW EXCLUSIVE on the parent, stalling writes under traffic. Scoping/integrity is
# enforced at the app layer.
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
"posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
diff --git a/products/data_catalog/backend/models/relationship_proposal.py b/products/data_catalog/backend/models/relationship_proposal.py
index a87261a5b61c..6d538e4b52d4 100644
--- a/products/data_catalog/backend/models/relationship_proposal.py
+++ b/products/data_catalog/backend/models/relationship_proposal.py
@@ -16,9 +16,9 @@ class RelationshipProposal(TeamScopedRootMixin, CreatedMetaFields, UpdatedMetaFi
unique ``undirected_fingerprint``.
"""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
source_table_name = models.CharField(max_length=400, help_text="Name of the table the join starts from.")
diff --git a/products/data_modeling/backend/migrations/0036_alter_dag_team_and_more.py b/products/data_modeling/backend/migrations/0036_alter_dag_team_and_more.py
new file mode 100644
index 000000000000..b511065e63ce
--- /dev/null
+++ b/products/data_modeling/backend/migrations/0036_alter_dag_team_and_more.py
@@ -0,0 +1,154 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("data_modeling", "0035_squash_2026_09_07_schema_addons"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ("warehouse_sources", "0161_alter_customoauth2integration_created_by_and_more"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="dag",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datawarehousemanagedviewset",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datawarehousemodelpath",
+ name="table",
+ field=models.ForeignKey(
+ default=None,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="warehouse_sources.datawarehousetable",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datawarehousemodelpath",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datawarehousesavedquery",
+ name="table",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="warehouse_sources.datawarehousetable",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datawarehousesavedquery",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datawarehousesavedquerycolumnannotation",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datawarehousesavedquerycolumnannotation",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datawarehousesavedquerydraft",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="edge",
+ name="team",
+ field=models.ForeignKey(
+ editable=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="githubsyncconfig",
+ name="integration",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="posthog.integration",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="githubsyncedmodel",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="githubsyncplan",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="node",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/data_modeling/backend/migrations/max_migration.txt b/products/data_modeling/backend/migrations/max_migration.txt
index 36e229988fab..5f56ee03e982 100644
--- a/products/data_modeling/backend/migrations/max_migration.txt
+++ b/products/data_modeling/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0035_squash_2026_09_07_schema_addons
+0036_alter_dag_team_and_more
diff --git a/products/data_modeling/backend/models/dag.py b/products/data_modeling/backend/models/dag.py
index 35cb598cc40f..afec81adafa7 100644
--- a/products/data_modeling/backend/models/dag.py
+++ b/products/data_modeling/backend/models/dag.py
@@ -18,7 +18,7 @@ RESERVED_DAG_NAMES = frozenset({DEFAULT_DAG_NAME, REVENUE_ANALYTICS_DAG_NAME})
class DAG(UUIDModel, CreatedMetaFields, UpdatedMetaFields):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
team_id: int
name = models.TextField(max_length=2048, db_index=True)
diff --git a/products/data_modeling/backend/models/datawarehouse_managed_viewset.py b/products/data_modeling/backend/models/datawarehouse_managed_viewset.py
index ff98a9a0e746..8dcad5e5ba48 100644
--- a/products/data_modeling/backend/models/datawarehouse_managed_viewset.py
+++ b/products/data_modeling/backend/models/datawarehouse_managed_viewset.py
@@ -42,7 +42,7 @@ class ExpectedView:
class DataWarehouseManagedViewSet(CreatedMetaFields, UpdatedMetaFields, UUIDTModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
kind = models.CharField(max_length=64, choices=DataWarehouseManagedViewSetKind)
class Meta:
diff --git a/products/data_modeling/backend/models/datawarehouse_saved_query.py b/products/data_modeling/backend/models/datawarehouse_saved_query.py
index 51e33d6330bd..6d6e0b137950 100644
--- a/products/data_modeling/backend/models/datawarehouse_saved_query.py
+++ b/products/data_modeling/backend/models/datawarehouse_saved_query.py
@@ -96,7 +96,7 @@ class DataWarehouseSavedQuery(CreatedMetaFields, UUIDTModel, UpdatedMetaFields,
MANAGED_VIEWSET = DataWarehouseSavedQueryOrigin.MANAGED_VIEWSET
name = models.CharField(max_length=128, validators=[validate_saved_query_name])
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
latest_error = models.TextField(default=None, null=True, blank=True)
columns = models.JSONField(
default=dict,
@@ -125,7 +125,9 @@ class DataWarehouseSavedQuery(CreatedMetaFields, UUIDTModel, UpdatedMetaFields,
sync_frequency_interval = models.DurationField(default=None, null=True, blank=True)
# In case the saved query is materialized to a table, this will be set
- table = models.ForeignKey("warehouse_sources.DataWarehouseTable", on_delete=models.SET_NULL, null=True, blank=True)
+ table = models.ForeignKey(
+ "warehouse_sources.DataWarehouseTable", on_delete=models.SET_NULL, null=True, blank=True, related_name="+"
+ )
is_materialized = models.BooleanField(default=False, blank=True, null=True)
# The name of the view at the time of soft deletion
diff --git a/products/data_modeling/backend/models/datawarehouse_saved_query_column_annotation.py b/products/data_modeling/backend/models/datawarehouse_saved_query_column_annotation.py
index dbae56fd4ab2..d04153f0a585 100644
--- a/products/data_modeling/backend/models/datawarehouse_saved_query_column_annotation.py
+++ b/products/data_modeling/backend/models/datawarehouse_saved_query_column_annotation.py
@@ -21,9 +21,9 @@ class DataWarehouseSavedQueryColumnAnnotation(TeamScopedRootMixin, CreatedMetaFi
# constraint takes a SHARE ROW EXCLUSIVE lock on the parent, which stalls under write traffic. Team
# scoping is enforced at the app level by TeamScopedRootMixin. The saved_query FK targets a non-hot
# table, so it keeps its constraint.
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
saved_query = models.ForeignKey(
"data_modeling.DataWarehouseSavedQuery", on_delete=models.CASCADE, related_name="column_annotations"
diff --git a/products/data_modeling/backend/models/datawarehouse_saved_query_draft.py b/products/data_modeling/backend/models/datawarehouse_saved_query_draft.py
index 560de19d27f6..4a44c1444a26 100644
--- a/products/data_modeling/backend/models/datawarehouse_saved_query_draft.py
+++ b/products/data_modeling/backend/models/datawarehouse_saved_query_draft.py
@@ -9,7 +9,7 @@ class DataWarehouseSavedQueryDraft(CreatedMetaFields, UpdatedMetaFields, UUIDTMo
before materializing them as actual saved queries.
"""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
query = models.JSONField(default=dict, blank=True, help_text="HogQL query draft")
# 255 should be safe. the max length of a view name is 128
diff --git a/products/data_modeling/backend/models/edge.py b/products/data_modeling/backend/models/edge.py
index 3e09f448cff3..440013d26471 100644
--- a/products/data_modeling/backend/models/edge.py
+++ b/products/data_modeling/backend/models/edge.py
@@ -53,7 +53,7 @@ class DataModelingEdgeManager(models.Manager):
class Edge(UUIDModel, CreatedMetaFields, UpdatedMetaFields):
objects = DataModelingEdgeManager()
- team = models.ForeignKey(Team, on_delete=models.CASCADE, editable=False)
+ team = models.ForeignKey(Team, on_delete=models.CASCADE, editable=False, related_name="+")
team_id: int
# the source node of the edge (i.e. the node this edge is pointed away from)
diff --git a/products/data_modeling/backend/models/github_sync_config.py b/products/data_modeling/backend/models/github_sync_config.py
index de844152c0b4..8568aba52e42 100644
--- a/products/data_modeling/backend/models/github_sync_config.py
+++ b/products/data_modeling/backend/models/github_sync_config.py
@@ -19,7 +19,9 @@ class GitHubSyncConfig(CreatedMetaFields, UpdatedMetaFields):
team = models.OneToOneField(Team, on_delete=models.CASCADE, primary_key=True)
team_id: int
- integration = models.ForeignKey("posthog.Integration", on_delete=models.SET_NULL, null=True, blank=True)
+ integration = models.ForeignKey(
+ "posthog.Integration", on_delete=models.SET_NULL, null=True, blank=True, related_name="+"
+ )
integration_id: int | None
repository = models.CharField(
diff --git a/products/data_modeling/backend/models/github_sync_plan.py b/products/data_modeling/backend/models/github_sync_plan.py
index d5884b552254..d53d652f1a93 100644
--- a/products/data_modeling/backend/models/github_sync_plan.py
+++ b/products/data_modeling/backend/models/github_sync_plan.py
@@ -12,7 +12,7 @@ class GitHubSyncPlanStatus(models.TextChoices):
class GitHubSyncPlan(UUIDModel, CreatedMetaFields, UpdatedMetaFields):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
team_id: int
config = models.ForeignKey("data_modeling.GitHubSyncConfig", on_delete=models.CASCADE, related_name="sync_plans")
diff --git a/products/data_modeling/backend/models/github_synced_model.py b/products/data_modeling/backend/models/github_synced_model.py
index d97c24254685..fc39b6670ef3 100644
--- a/products/data_modeling/backend/models/github_synced_model.py
+++ b/products/data_modeling/backend/models/github_synced_model.py
@@ -4,7 +4,7 @@ from posthog.models.utils import CreatedMetaFields, UpdatedMetaFields, UUIDModel
class GitHubSyncedModel(UUIDModel, CreatedMetaFields, UpdatedMetaFields):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
team_id: int
config = models.ForeignKey(
diff --git a/products/data_modeling/backend/models/modeling.py b/products/data_modeling/backend/models/modeling.py
index 97d8bf6165a4..fb58d93f5da9 100644
--- a/products/data_modeling/backend/models/modeling.py
+++ b/products/data_modeling/backend/models/modeling.py
@@ -1033,9 +1033,9 @@ class DataWarehouseModelPath(CreatedMetaFields, UpdatedMetaFields, UUIDTModel):
objects: DataWarehouseModelPathManager = DataWarehouseModelPathManager()
path = LabelTreeField(null=False)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
table = models.ForeignKey(
- "warehouse_sources.DataWarehouseTable", null=True, default=None, on_delete=models.SET_NULL
+ "warehouse_sources.DataWarehouseTable", null=True, default=None, on_delete=models.SET_NULL, related_name="+"
)
saved_query = models.ForeignKey(
"data_modeling.DataWarehouseSavedQuery", null=True, default=None, on_delete=models.SET_NULL
diff --git a/products/data_modeling/backend/models/node.py b/products/data_modeling/backend/models/node.py
index 681e9b9f0af2..b739dfe89a14 100644
--- a/products/data_modeling/backend/models/node.py
+++ b/products/data_modeling/backend/models/node.py
@@ -17,7 +17,7 @@ class NodeType(models.TextChoices):
class Node(UUIDModel, CreatedMetaFields, UpdatedMetaFields):
- team = models.ForeignKey(Team, on_delete=models.CASCADE)
+ team = models.ForeignKey(Team, on_delete=models.CASCADE, related_name="+")
team_id: int
# models.PROTECT prevents deleting a saved query if its referenced by a Node
diff --git a/products/data_quality/backend/migrations/0008_alter_dataqualitycheck_team_and_more.py b/products/data_quality/backend/migrations/0008_alter_dataqualitycheck_team_and_more.py
new file mode 100644
index 000000000000..94dae4d6e794
--- /dev/null
+++ b/products/data_quality/backend/migrations/0008_alter_dataqualitycheck_team_and_more.py
@@ -0,0 +1,56 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("data_quality", "0007_dataqualitycheck_failing_since"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="dataqualitycheck",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="dataqualitycheckrun",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="dataqualitysuiterun",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="teamdataqualityconfig",
+ name="team",
+ field=models.OneToOneField(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ related_name="+",
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/data_quality/backend/migrations/max_migration.txt b/products/data_quality/backend/migrations/max_migration.txt
index 528470415f5a..5c1882d8844f 100644
--- a/products/data_quality/backend/migrations/max_migration.txt
+++ b/products/data_quality/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0007_dataqualitycheck_failing_since
+0008_alter_dataqualitycheck_team_and_more
diff --git a/products/data_quality/backend/models/check.py b/products/data_quality/backend/models/check.py
index eaa21a52bd8e..ce9c6d7fe421 100644
--- a/products/data_quality/backend/models/check.py
+++ b/products/data_quality/backend/models/check.py
@@ -77,7 +77,7 @@ class DataQualityCheck(
# db_constraint=False on FKs to hot tables (posthog_team, posthog_user): a real FK constraint
# takes SHARE ROW EXCLUSIVE on the parent, stalling writes under traffic. Scoping/integrity is
# enforced at the app layer.
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
"posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
diff --git a/products/data_quality/backend/models/check_run.py b/products/data_quality/backend/models/check_run.py
index 5fc80332bb94..c5dbd1268daf 100644
--- a/products/data_quality/backend/models/check_run.py
+++ b/products/data_quality/backend/models/check_run.py
@@ -14,7 +14,7 @@ class DataQualitySuiteRun(TeamScopedRootMixin, CreatedMetaFields, UpdatedMetaFie
columns are a convenience for the common single-subject case, not the run's identity.
"""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
"posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
@@ -76,7 +76,7 @@ class DataQualityCheckRun(TeamScopedRootMixin, CreatedMetaFields, UpdatedMetaFie
series is what future anomaly-detection check types train on.
"""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
"posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
diff --git a/products/data_quality/backend/models/team_data_quality_config.py b/products/data_quality/backend/models/team_data_quality_config.py
index cc2dad100705..a98f99fec585 100644
--- a/products/data_quality/backend/models/team_data_quality_config.py
+++ b/products/data_quality/backend/models/team_data_quality_config.py
@@ -17,7 +17,7 @@ class TeamDataQualityConfig(models.Model):
# db_constraint=False: a real FK constraint takes SHARE ROW EXCLUSIVE on posthog_team while
# migrating, stalling writes under traffic.
- team = models.OneToOneField(Team, on_delete=models.CASCADE, primary_key=True, db_constraint=False)
+ team = models.OneToOneField(Team, on_delete=models.CASCADE, primary_key=True, db_constraint=False, related_name="+")
gate_materialization_on_checks = models.BooleanField(
default=False,
diff --git a/products/data_tools/backend/migrations/0002_alter_datawarehouseexpression_created_by_and_more.py b/products/data_tools/backend/migrations/0002_alter_datawarehouseexpression_created_by_and_more.py
new file mode 100644
index 000000000000..c599e6eb2a73
--- /dev/null
+++ b/products/data_tools/backend/migrations/0002_alter_datawarehouseexpression_created_by_and_more.py
@@ -0,0 +1,84 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("data_modeling", "0036_alter_dag_team_and_more"),
+ ("data_tools", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="datawarehouseexpression",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datawarehouseexpression",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datawarehousejoin",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datawarehousesavedqueryfolder",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datawarehouseviewlink",
+ name="saved_query",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="data_modeling.datawarehousesavedquery",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datawarehouseviewlink",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="querytabstate",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/data_tools/backend/migrations/max_migration.txt b/products/data_tools/backend/migrations/max_migration.txt
index 6903cd5e3dc2..9a15cc203d0e 100644
--- a/products/data_tools/backend/migrations/max_migration.txt
+++ b/products/data_tools/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_squash_2026_09_07_initial
+0002_alter_datawarehouseexpression_created_by_and_more
diff --git a/products/data_tools/backend/models/datawarehouse_saved_query_folder.py b/products/data_tools/backend/models/datawarehouse_saved_query_folder.py
index 1a8780aa0220..86fed897b127 100644
--- a/products/data_tools/backend/models/datawarehouse_saved_query_folder.py
+++ b/products/data_tools/backend/models/datawarehouse_saved_query_folder.py
@@ -8,7 +8,7 @@ class DataWarehouseSavedQueryFolder(CreatedMetaFields, UUIDTModel, UpdatedMetaFi
max_length=128,
help_text="Display name for the folder used to organize saved queries in the SQL editor sidebar.",
)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
class Meta:
constraints = [
diff --git a/products/data_tools/backend/models/expression.py b/products/data_tools/backend/models/expression.py
index a639cb5840cb..b985ef76d92a 100644
--- a/products/data_tools/backend/models/expression.py
+++ b/products/data_tools/backend/models/expression.py
@@ -17,10 +17,15 @@ class DataWarehouseExpression(ModelActivityMixin, TeamScopedRootMixin, UUIDTMode
# db_constraint=False on the hot-table FKs (team, created_by) so CreateModel takes no lock
# on posthog_team / posthog_user; app-level enforcement is enough here.
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_at = models.DateTimeField(auto_now_add=True, blank=True)
created_by = models.ForeignKey(
- settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ settings.AUTH_USER_MODEL,
+ on_delete=models.SET_NULL,
+ null=True,
+ blank=True,
+ db_constraint=False,
+ related_name="+",
)
table_name = models.CharField(max_length=400)
field_name = models.CharField(max_length=400)
diff --git a/products/data_tools/backend/models/join.py b/products/data_tools/backend/models/join.py
index 5eee170aef45..8af40e4bb039 100644
--- a/products/data_tools/backend/models/join.py
+++ b/products/data_tools/backend/models/join.py
@@ -23,15 +23,15 @@ class DataWarehouseViewLink(CreatedMetaFields, UUIDTModel, DeletedMetaFields):
warn("DataWarehouseViewLink is deprecated, use DataWarehouseJoin", DeprecationWarning, stacklevel=2)
super().__init__(*args, **kwargs)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
table = models.CharField(max_length=128)
from_join_key = models.CharField(max_length=400)
- saved_query = models.ForeignKey("data_modeling.DataWarehouseSavedQuery", on_delete=models.CASCADE)
+ saved_query = models.ForeignKey("data_modeling.DataWarehouseSavedQuery", on_delete=models.CASCADE, related_name="+")
to_join_key = models.CharField(max_length=400)
class DataWarehouseJoin(CreatedMetaFields, UUIDTModel, DeletedMetaFields):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
source_table_name = models.CharField(max_length=400)
source_table_key = models.CharField(max_length=400)
joining_table_name = models.CharField(max_length=400)
diff --git a/products/data_tools/backend/models/query_tab_state.py b/products/data_tools/backend/models/query_tab_state.py
index 464a583bc0a3..ffb1568ef39e 100644
--- a/products/data_tools/backend/models/query_tab_state.py
+++ b/products/data_tools/backend/models/query_tab_state.py
@@ -4,7 +4,7 @@ from posthog.models.utils import CreatedMetaFields, DeletedMetaFields, UUIDTMode
class QueryTabState(CreatedMetaFields, UUIDTModel, DeletedMetaFields):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
state = models.JSONField(
default=dict,
null=True,
diff --git a/products/data_warehouse/backend/migrations/0058_alter_managedwarehousebackfillpartition_team.py b/products/data_warehouse/backend/migrations/0058_alter_managedwarehousebackfillpartition_team.py
new file mode 100644
index 000000000000..e8d7ca16d3f5
--- /dev/null
+++ b/products/data_warehouse/backend/migrations/0058_alter_managedwarehousebackfillpartition_team.py
@@ -0,0 +1,24 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("data_warehouse", "0057_managed_warehouse_backfill_partition"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="managedwarehousebackfillpartition",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/data_warehouse/backend/migrations/max_migration.txt b/products/data_warehouse/backend/migrations/max_migration.txt
index 8e260d1f6a7d..23ed9168b498 100644
--- a/products/data_warehouse/backend/migrations/max_migration.txt
+++ b/products/data_warehouse/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0057_managed_warehouse_backfill_partition
+0058_alter_managedwarehousebackfillpartition_team
diff --git a/products/data_warehouse/backend/models/managed_warehouse_backfill_partition.py b/products/data_warehouse/backend/models/managed_warehouse_backfill_partition.py
index 3467ba81dee1..c80462f71e8b 100644
--- a/products/data_warehouse/backend/models/managed_warehouse_backfill_partition.py
+++ b/products/data_warehouse/backend/models/managed_warehouse_backfill_partition.py
@@ -21,7 +21,7 @@ class ManagedWarehouseBackfillPartition(TeamScopedRootMixin, UUIDModel):
# team is the canonical tenant boundary; environment_id preserves the exact
# project because sibling environments share a team scope.
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
environment_id = models.BigIntegerField()
dataset = models.CharField(max_length=16, choices=Dataset.choices)
# partition_key is whatever the scheduler calls this unit of work — opaque here, and only
diff --git a/products/endpoints/backend/migrations/0032_alter_endpoint_created_by_alter_endpoint_team_and_more.py b/products/endpoints/backend/migrations/0032_alter_endpoint_created_by_alter_endpoint_team_and_more.py
new file mode 100644
index 000000000000..50ebaaaf266b
--- /dev/null
+++ b/products/endpoints/backend/migrations/0032_alter_endpoint_created_by_alter_endpoint_team_and_more.py
@@ -0,0 +1,47 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("endpoints", "0031_endpointversion_optional_breakdown_properties"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="endpoint",
+ 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="endpoint",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="endpointversion",
+ name="team",
+ field=models.ForeignKey(
+ help_text="Team this version belongs to (denormalized from endpoint for HogQL system table access)",
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/endpoints/backend/migrations/max_migration.txt b/products/endpoints/backend/migrations/max_migration.txt
index 10969429e573..59e02ce7185f 100644
--- a/products/endpoints/backend/migrations/max_migration.txt
+++ b/products/endpoints/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0031_endpointversion_optional_breakdown_properties
+0032_alter_endpoint_created_by_alter_endpoint_team_and_more
diff --git a/products/endpoints/backend/models.py b/products/endpoints/backend/models.py
index 980e6279c5f6..e82f13822ffd 100644
--- a/products/endpoints/backend/models.py
+++ b/products/endpoints/backend/models.py
@@ -186,6 +186,7 @@ class EndpointVersion(UpdatedMetaFields, models.Model):
on_delete=models.CASCADE,
null=True,
help_text="Team this version belongs to (denormalized from endpoint for HogQL system table access)",
+ related_name="+",
)
version = models.IntegerField()
query = models.JSONField(help_text="Immutable query snapshot")
@@ -368,7 +369,7 @@ class Endpoint(CreatedMetaFields, UpdatedMetaFields, DeletedMetaFields, UUIDTMod
validators=[validate_endpoint_name],
help_text="URL-safe name for the endpoint",
)
- team = models.ForeignKey(Team, on_delete=models.CASCADE)
+ team = models.ForeignKey(Team, on_delete=models.CASCADE, related_name="+")
derived_from_insight = models.CharField(
max_length=12,
@@ -381,7 +382,7 @@ class Endpoint(CreatedMetaFields, UpdatedMetaFields, DeletedMetaFields, UUIDTMod
current_version = models.IntegerField(default=1, help_text="Current version number of the endpoint query")
- created_by = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True)
+ created_by = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True, related_name="+")
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
last_executed_at = models.DateTimeField(
diff --git a/products/error_tracking/backend/migrations/0034_alter_errortrackingassignmentrule_role_and_more.py b/products/error_tracking/backend/migrations/0034_alter_errortrackingassignmentrule_role_and_more.py
new file mode 100644
index 000000000000..0f123e62be3e
--- /dev/null
+++ b/products/error_tracking/backend/migrations/0034_alter_errortrackingassignmentrule_role_and_more.py
@@ -0,0 +1,238 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("cohorts", "0014_alter_cohort_created_by_alter_cohort_people_and_more"),
+ ("ee", "0063_scim_provisioned_user_config_set_null"),
+ ("error_tracking", "0033_squash_2026_09_07_schema_addons"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="errortrackingassignmentrule",
+ name="role",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="ee.role",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingassignmentrule",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingassignmentrule",
+ name="user",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingautocapturecontrols",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingbypassrule",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingexternalreference",
+ name="integration",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.integration",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackinggroup",
+ name="assignee",
+ 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="errortrackinggroup",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackinggroupingrule",
+ name="role",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="ee.role",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackinggroupingrule",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackinggroupingrule",
+ name="user",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingissue",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingissueassignment",
+ name="role",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="ee.role",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingissueassignment",
+ name="team",
+ field=models.ForeignKey(
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingissueassignment",
+ name="user",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingissuecohort",
+ name="cohort",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="cohorts.cohort",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingissuefingerprint",
+ name="team",
+ field=models.ForeignKey(
+ db_index=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingissuefingerprintv2",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingrelease",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingseverityrule",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingspikeevent",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingsuppressionrule",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="errortrackingsymbolset",
+ 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.txt
index a04bc7b07031..001262b6acdc 100644
--- a/products/error_tracking/backend/migrations/max_migration.txt
+++ b/products/error_tracking/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0033_squash_2026_09_07_schema_addons
+0034_alter_errortrackingassignmentrule_role_and_more
diff --git a/products/error_tracking/backend/models.py b/products/error_tracking/backend/models.py
index 43a880668152..16e533ebd332 100644
--- a/products/error_tracking/backend/models.py
+++ b/products/error_tracking/backend/models.py
@@ -69,7 +69,7 @@ class ErrorTrackingIssue(UUIDTModel):
HIGH = "high", "High"
CRITICAL = "critical", "Critical"
- 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)
state_updated_at = models.DateTimeField(null=True, blank=True)
status = models.TextField(choices=Status, default=Status.ACTIVE, null=False)
@@ -190,10 +190,7 @@ class ErrorTrackingExternalReference(UUIDTModel):
related_name="external_issues",
related_query_name="external_issue",
)
- integration = models.ForeignKey(
- Integration,
- on_delete=models.CASCADE,
- )
+ integration = models.ForeignKey(Integration, on_delete=models.CASCADE, related_name="+")
# DEPRECATED: provider can be fetched through the integration model
provider = deprecate_field(models.TextField(null=False, blank=False))
# DEPRECATED: ids should be placed inside the external_context json field
@@ -211,10 +208,7 @@ class ErrorTrackingIssueCohort(UUIDTModel):
on_delete=models.CASCADE,
related_name="cohorts",
)
- cohort = models.ForeignKey(
- "cohorts.Cohort",
- on_delete=models.CASCADE,
- )
+ cohort = models.ForeignKey("cohorts.Cohort", on_delete=models.CASCADE, related_name="+")
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
@@ -225,11 +219,11 @@ class ErrorTrackingIssueCohort(UUIDTModel):
class ErrorTrackingIssueAssignment(UUIDTModel):
issue = models.OneToOneField(ErrorTrackingIssue, on_delete=models.CASCADE, related_name="assignment")
- team = models.ForeignKey("posthog.Team", null=True, on_delete=models.CASCADE, db_index=False)
- user = models.ForeignKey("posthog.User", null=True, on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", null=True, on_delete=models.CASCADE, db_index=False, related_name="+")
+ user = models.ForeignKey("posthog.User", null=True, on_delete=models.CASCADE, related_name="+")
# DEPRECATED: issues can only be assigned to users or roles
user_group = deprecate_field(models.ForeignKey("posthog.UserGroup", null=True, on_delete=models.CASCADE))
- role = models.ForeignKey("ee.Role", null=True, on_delete=models.CASCADE)
+ role = models.ForeignKey("ee.Role", null=True, on_delete=models.CASCADE, related_name="+")
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
@@ -240,7 +234,7 @@ class ErrorTrackingIssueAssignment(UUIDTModel):
class ErrorTrackingIssueFingerprintV2(UUIDTModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
issue = models.ForeignKey(ErrorTrackingIssue, on_delete=models.CASCADE, related_name="fingerprints")
fingerprint = models.TextField(null=False, blank=False)
# current version of the id, used to sync with ClickHouse and collapse rows correctly for overrides ClickHouse table
@@ -334,7 +328,7 @@ def _sync_error_tracking_issue_changes_on_commit(
class ErrorTrackingRelease(UUIDTModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
# On upload, users can provide a hash of some key identifiers, e.g. "git repo, commit, branch"
# or similar, which we guarantee to be unique. If a user doesn't provide a hash_id, we use the
# id of the model - TODO - should this instead by a hash of the project and version?
@@ -376,7 +370,7 @@ def symbol_set_cleanup_bucket_expression() -> models.Func:
class ErrorTrackingSymbolSet(UUIDTModel):
# Derived from the symbol set reference
ref = models.TextField(null=False, blank=False)
- 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)
# How we stored this symbol set, and where to look for it
# These are null if we failed to find a symbol set for a given reference. We store a
@@ -431,11 +425,11 @@ class ErrorTrackingSymbolSet(UUIDTModel):
class ErrorTrackingAssignmentRule(UUIDTModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
- user = models.ForeignKey("posthog.User", null=True, on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
+ user = models.ForeignKey("posthog.User", null=True, on_delete=models.CASCADE, related_name="+")
# DEPRECATED: issues can only be assigned to users or roles
user_group = deprecate_field(models.ForeignKey("posthog.UserGroup", null=True, on_delete=models.CASCADE))
- role = models.ForeignKey("ee.Role", null=True, on_delete=models.CASCADE)
+ role = models.ForeignKey("ee.Role", null=True, on_delete=models.CASCADE, related_name="+")
order_key = models.IntegerField(null=False, blank=False)
bytecode = models.JSONField(null=False, blank=False) # The bytecode of the rule
filters = models.JSONField(null=False, blank=False) # The json object describing the filter rule
@@ -458,7 +452,7 @@ class ErrorTrackingAssignmentRule(UUIDTModel):
class ErrorTrackingSeverityRule(TeamScopedRootMixin, UUIDTModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
filters = models.JSONField(null=False, blank=False)
bytecode = models.JSONField(null=False, blank=False)
severity = models.TextField(choices=ErrorTrackingIssue.Severity)
@@ -480,7 +474,7 @@ class ErrorTrackingSeverityRule(TeamScopedRootMixin, UUIDTModel):
# This means "custom issues" can still be merged and otherwise handled as you'd expect, just that
# the set of events that end up in them will be different from the default grouping rules.
class ErrorTrackingGroupingRule(UUIDTModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
bytecode = models.JSONField(null=False, blank=False) # The bytecode of the rule
filters = models.JSONField(null=False, blank=False) # The json object describing the filter rule
created_at = models.DateTimeField(auto_now_add=True)
@@ -494,10 +488,10 @@ class ErrorTrackingGroupingRule(UUIDTModel):
# We allow grouping rules to also auto-assign, and if they do, assignment rules are ignored
# in favour of the assignment of the grouping rule. Notably this differs from assignment rules
# in so far as we permit all of these to be null
- user = models.ForeignKey("posthog.User", null=True, on_delete=models.CASCADE)
+ user = models.ForeignKey("posthog.User", null=True, on_delete=models.CASCADE, related_name="+")
# DEPRECATED: issues can only be assigned to users or roles
user_group = deprecate_field(models.ForeignKey("posthog.UserGroup", null=True, on_delete=models.CASCADE))
- role = models.ForeignKey("ee.Role", null=True, on_delete=models.CASCADE)
+ role = models.ForeignKey("ee.Role", null=True, on_delete=models.CASCADE, related_name="+")
# Users will probably find it convenient to be able to add a short description to grouping rules
description = models.TextField(null=True)
@@ -515,7 +509,7 @@ class ErrorTrackingGroupingRule(UUIDTModel):
class ErrorTrackingSuppressionRule(UUIDTModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
filters = models.JSONField(null=False, blank=False) # The json object describing the filter rule
bytecode = models.JSONField(null=True, blank=True)
disabled_data = models.JSONField(null=True, blank=True)
@@ -546,7 +540,7 @@ class ErrorTrackingBypassRule(UUIDTModel):
# affect suppression, which runs earlier.
# db_constraint=False keeps the create lock-free on posthog_team (a hot table); team scoping
# is enforced at the ORM layer and Cymbal reads by team_id via raw SQL.
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
filters = models.JSONField(null=False, blank=False) # The json object describing the filter rule
bytecode = models.JSONField(null=True, blank=True)
disabled_data = models.JSONField(null=True, blank=True)
@@ -576,7 +570,7 @@ class ErrorTrackingAutoCaptureControls(UUIDTModel):
class Library(models.TextChoices):
WEB = "web"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
library = models.CharField(max_length=24, choices=Library, null=False, blank=False, default=Library.WEB)
match_type = models.CharField(max_length=24, choices=MatchType, null=False, blank=False, default=MatchType.ALL)
@@ -640,7 +634,7 @@ class ErrorTrackingGroup(UUIDTModel):
RESOLVED = "resolved", "Resolved"
PENDING_RELEASE = "pending_release", "Pending release"
- 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, blank=True)
fingerprint: ArrayField = ArrayField(models.TextField(null=False, blank=False), null=False, blank=False)
merged_fingerprints: ArrayField = ArrayField(
@@ -650,12 +644,7 @@ class ErrorTrackingGroup(UUIDTModel):
default=list,
)
status = models.CharField(max_length=40, choices=Status, default=Status.ACTIVE, null=False)
- assignee = models.ForeignKey(
- "posthog.User",
- on_delete=models.SET_NULL,
- null=True,
- blank=True,
- )
+ assignee = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True, related_name="+")
class Meta:
db_table = "posthog_errortrackinggroup"
@@ -663,7 +652,7 @@ class ErrorTrackingGroup(UUIDTModel):
# DEPRECATED: Use ErrorTrackingIssueFingerprintV2 instead
class ErrorTrackingIssueFingerprint(models.Model):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_index=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_index=False, related_name="+")
issue = models.ForeignKey(ErrorTrackingGroup, on_delete=models.CASCADE)
fingerprint = models.TextField(null=False, blank=False)
# current version of the id, used to sync with ClickHouse and collapse rows correctly for overrides ClickHouse table
@@ -846,7 +835,7 @@ class ErrorTrackingSettings(models.Model):
class ErrorTrackingSpikeEvent(UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
issue = models.ForeignKey(ErrorTrackingIssue, on_delete=models.CASCADE, related_name="spike_events")
detected_at = models.DateTimeField()
computed_baseline = models.FloatField()
diff --git a/products/event_definitions/backend/migrations/0012_alter_eventdefinition_project_and_more.py b/products/event_definitions/backend/migrations/0012_alter_eventdefinition_project_and_more.py
new file mode 100644
index 000000000000..9be57da35aac
--- /dev/null
+++ b/products/event_definitions/backend/migrations/0012_alter_eventdefinition_project_and_more.py
@@ -0,0 +1,64 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("event_definitions", "0011_propertydefinition_feature_flag_idx"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="eventdefinition",
+ name="project",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.project",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="eventproperty",
+ name="project",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.project",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="eventproperty",
+ name="team",
+ field=models.ForeignKey(
+ db_index=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="propertydefinition",
+ name="project",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.project",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="schemapropertygroup",
+ name="project",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.project",
+ ),
+ ),
+ ]
diff --git a/products/event_definitions/backend/migrations/max_migration.txt b/products/event_definitions/backend/migrations/max_migration.txt
index eb9c26a1202f..ee559ba63df4 100644
--- a/products/event_definitions/backend/migrations/max_migration.txt
+++ b/products/event_definitions/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0011_propertydefinition_feature_flag_idx
+0012_alter_eventdefinition_project_and_more
diff --git a/products/event_definitions/backend/models/event_definition.py b/products/event_definitions/backend/models/event_definition.py
index 2c34cfbcf28a..503424be9cac 100644
--- a/products/event_definitions/backend/models/event_definition.py
+++ b/products/event_definitions/backend/models/event_definition.py
@@ -22,7 +22,7 @@ class EventDefinition(UUIDTModel):
related_name="event_definitions",
related_query_name="team",
)
- project = models.ForeignKey("posthog.Project", on_delete=models.CASCADE, null=True)
+ project = models.ForeignKey("posthog.Project", on_delete=models.CASCADE, null=True, related_name="+")
name = models.CharField(max_length=400)
created_at = models.DateTimeField(default=timezone.now, null=True)
last_seen_at = models.DateTimeField(default=None, null=True)
diff --git a/products/event_definitions/backend/models/event_property.py b/products/event_definitions/backend/models/event_property.py
index bdf9159949f3..bfdcc99c1490 100644
--- a/products/event_definitions/backend/models/event_property.py
+++ b/products/event_definitions/backend/models/event_property.py
@@ -5,8 +5,8 @@ from posthog.models.utils import UniqueConstraintByExpression, sane_repr
class EventProperty(models.Model):
id = models.BigAutoField(primary_key=True)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_index=False)
- project = models.ForeignKey("posthog.Project", on_delete=models.CASCADE, null=True)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_index=False, related_name="+")
+ project = models.ForeignKey("posthog.Project", on_delete=models.CASCADE, null=True, related_name="+")
event = models.CharField(max_length=400, null=False)
property = models.CharField(max_length=400, null=False)
diff --git a/products/event_definitions/backend/models/property_definition.py b/products/event_definitions/backend/models/property_definition.py
index 05dabca11453..afe958071802 100644
--- a/products/event_definitions/backend/models/property_definition.py
+++ b/products/event_definitions/backend/models/property_definition.py
@@ -63,7 +63,7 @@ class PropertyDefinition(UUIDTModel):
related_name="property_definitions",
related_query_name="team",
)
- project = models.ForeignKey("posthog.Project", on_delete=models.CASCADE, null=True)
+ project = models.ForeignKey("posthog.Project", on_delete=models.CASCADE, null=True, related_name="+")
name = models.CharField(max_length=400)
is_numerical = models.BooleanField(
default=False
diff --git a/products/event_definitions/backend/models/schema.py b/products/event_definitions/backend/models/schema.py
index d99717c6ebfb..584a94d64fdf 100644
--- a/products/event_definitions/backend/models/schema.py
+++ b/products/event_definitions/backend/models/schema.py
@@ -28,7 +28,7 @@ class SchemaPropertyGroup(UUIDTModel):
related_name="schema_property_groups",
related_query_name="schema_property_group",
)
- project = models.ForeignKey("posthog.Project", on_delete=models.CASCADE, null=True)
+ project = models.ForeignKey("posthog.Project", on_delete=models.CASCADE, null=True, related_name="+")
name = models.CharField(max_length=400)
description = models.TextField(blank=True)
created_at = models.DateTimeField(default=timezone.now)
diff --git a/products/experiments/backend/migrations/0038_alter_experimentholdout_created_by_and_more.py b/products/experiments/backend/migrations/0038_alter_experimentholdout_created_by_and_more.py
new file mode 100644
index 000000000000..ae819397585c
--- /dev/null
+++ b/products/experiments/backend/migrations/0038_alter_experimentholdout_created_by_and_more.py
@@ -0,0 +1,83 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("experiments", "0037_squash_2026_09_07_finalize_fks"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="experimentholdout",
+ name="created_by",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="experimentholdout",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="experimentmetricsrecalculation",
+ 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="experimentmetricsrecalculation",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="experimentsavedmetric",
+ name="created_by",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="experimentsavedmetric",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="experimenttimeseriesrecalculation",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/experiments/backend/migrations/max_migration.txt b/products/experiments/backend/migrations/max_migration.txt
index 22c7378ce572..f1248139c010 100644
--- a/products/experiments/backend/migrations/max_migration.txt
+++ b/products/experiments/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0037_squash_2026_09_07_finalize_fks
+0038_alter_experimentholdout_created_by_and_more
diff --git a/products/experiments/backend/models/experiment.py b/products/experiments/backend/models/experiment.py
index ce872b6679ad..8abf9b4db609 100644
--- a/products/experiments/backend/models/experiment.py
+++ b/products/experiments/backend/models/experiment.py
@@ -375,13 +375,13 @@ def saved_metric_has_legacy_query(saved_metric: "ExperimentSavedMetric") -> bool
class ExperimentHoldout(ModelActivityMixin, RootTeamMixin, models.Model):
name = models.CharField(max_length=400)
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 define the definition of the holdout
# This is then replicated across flags for experiments in the holdout
filters = models.JSONField(default=list)
- created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True)
+ created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, related_name="+")
created_at = models.DateTimeField(default=timezone.now)
updated_at = models.DateTimeField(auto_now=True)
@@ -405,7 +405,7 @@ class ExperimentHoldout(ModelActivityMixin, RootTeamMixin, models.Model):
class ExperimentSavedMetric(ModelActivityMixin, RootTeamMixin, models.Model):
name = models.CharField(max_length=400)
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="+")
query = models.JSONField()
@@ -413,7 +413,7 @@ class ExperimentSavedMetric(ModelActivityMixin, RootTeamMixin, models.Model):
# has things like if this metric was migrated from a legacy metric
metadata = models.JSONField(null=True, blank=True, default=dict)
- created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True)
+ created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, related_name="+")
created_at = models.DateTimeField(default=timezone.now)
updated_at = models.DateTimeField(auto_now=True)
@@ -478,7 +478,7 @@ class ExperimentTimeseriesRecalculation(UUIDModel):
COMPLETED = "completed", "Completed"
FAILED = "failed", "Failed"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
experiment = models.ForeignKey("Experiment", on_delete=models.CASCADE)
metric = models.JSONField()
fingerprint = models.CharField(max_length=64) # SHA256 hash
@@ -536,7 +536,7 @@ class ExperimentMetricsRecalculation(TeamScopedRootMixin, UUIDModel):
EXPERIMENT_STOP = "experiment_stop", "Experiment Stop"
EXPERIMENT_UPDATE = "experiment_update", "Experiment Update"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
experiment = models.ForeignKey("Experiment", on_delete=models.CASCADE)
status = models.CharField(max_length=20, choices=Status, default=Status.PENDING)
@@ -553,12 +553,7 @@ class ExperimentMetricsRecalculation(TeamScopedRootMixin, UUIDModel):
created_at = models.DateTimeField(auto_now_add=True)
started_at = models.DateTimeField(null=True, blank=True)
completed_at = models.DateTimeField(null=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="+")
class Meta:
indexes = [
diff --git a/products/exports/backend/migrations/0012_alter_subscription_created_by_and_more.py b/products/exports/backend/migrations/0012_alter_subscription_created_by_and_more.py
new file mode 100644
index 000000000000..fe4417a517a1
--- /dev/null
+++ b/products/exports/backend/migrations/0012_alter_subscription_created_by_and_more.py
@@ -0,0 +1,82 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+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",
+ ),
+ ("exports", "0011_exportedasset_exportedasset_system_session"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ("product_analytics", "0009_alter_insightvariable_team"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="subscription",
+ 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="subscription",
+ name="dashboard",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="dashboards.dashboard",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="subscription",
+ name="insight",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="product_analytics.insight",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="subscription",
+ name="integration",
+ field=models.ForeignKey(
+ blank=True,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="posthog.integration",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="subscription",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="subscriptiondelivery",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/exports/backend/migrations/max_migration.txt b/products/exports/backend/migrations/max_migration.txt
index 1961b8cce020..904a1c727c4e 100644
--- a/products/exports/backend/migrations/max_migration.txt
+++ b/products/exports/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0011_exportedasset_exportedasset_system_session
+0012_alter_subscription_created_by_and_more
diff --git a/products/exports/backend/models/subscription.py b/products/exports/backend/models/subscription.py
index b67b5ff77bf3..9fef749889f8 100644
--- a/products/exports/backend/models/subscription.py
+++ b/products/exports/backend/models/subscription.py
@@ -159,20 +159,16 @@ class Subscription(ModelActivityMixin, models.Model):
DEFAULT_AI_REPORT_WINDOW_DAYS = 7
# Relations - i.e. WHAT are we exporting?
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
- dashboard = models.ForeignKey("dashboards.Dashboard", on_delete=models.CASCADE, null=True)
- insight = models.ForeignKey("product_analytics.Insight", on_delete=models.CASCADE, null=True)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
+ dashboard = models.ForeignKey("dashboards.Dashboard", on_delete=models.CASCADE, null=True, related_name="+")
+ insight = models.ForeignKey("product_analytics.Insight", on_delete=models.CASCADE, null=True, related_name="+")
dashboard_export_insights = models.ManyToManyField(
"product_analytics.Insight",
blank=True,
related_name="subscriptions_dashboard_export",
)
integration = models.ForeignKey(
- "posthog.Integration",
- on_delete=models.SET_NULL,
- null=True,
- blank=True,
- db_index=False,
+ "posthog.Integration", on_delete=models.SET_NULL, null=True, blank=True, db_index=False, related_name="+"
)
prompt = models.TextField(null=True, blank=True)
@@ -209,7 +205,7 @@ class Subscription(ModelActivityMixin, models.Model):
# Meta
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)
# False when paused or auto-disabled because the delivery prerequisite is
@@ -602,7 +598,7 @@ class SubscriptionDelivery(UUIDModel):
SKIPPED = "skipped"
subscription = models.ForeignKey("Subscription", on_delete=models.CASCADE, related_name="deliveries")
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
# Temporal correlation — workflow_id for debugging, idempotency_key for dedup.
# idempotency_key is generated via temporalio.workflow.uuid4() which is deterministic
diff --git a/products/feature_flags/backend/migrations/0020_alter_featureflag_created_by_alter_featureflag_team_and_more.py b/products/feature_flags/backend/migrations/0020_alter_featureflag_created_by_alter_featureflag_team_and_more.py
new file mode 100644
index 000000000000..0d39439583ac
--- /dev/null
+++ b/products/feature_flags/backend/migrations/0020_alter_featureflag_created_by_alter_featureflag_team_and_more.py
@@ -0,0 +1,107 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+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",
+ ),
+ ("feature_flags", "0019_squash_2026_09_07_schema_addons"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="featureflag",
+ name="created_by",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="featureflag",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="featureflag",
+ name="usage_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="featureflagdashboards",
+ name="dashboard",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="dashboards.dashboard",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="featureflagoverride",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="featureflagoverride",
+ name="user",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="scheduledchange",
+ name="created_by",
+ field=models.ForeignKey(
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="scheduledchange",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="teamfeatureflagdefaultsconfig",
+ 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/feature_flags/backend/migrations/max_migration.txt b/products/feature_flags/backend/migrations/max_migration.txt
index 814d850ec43c..b38a02e326a8 100644
--- a/products/feature_flags/backend/migrations/max_migration.txt
+++ b/products/feature_flags/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0019_squash_2026_09_07_schema_addons
+0020_alter_featureflag_created_by_alter_featureflag_team_and_more
diff --git a/products/feature_flags/backend/models/feature_flag.py b/products/feature_flags/backend/models/feature_flag.py
index 4963cca2f1f4..991ba4a77657 100644
--- a/products/feature_flags/backend/models/feature_flag.py
+++ b/products/feature_flags/backend/models/feature_flag.py
@@ -151,8 +151,8 @@ class FeatureFlag(FileSystemSyncMixin, ModelActivityMixin, RootTeamMixin, models
# DEPRECATED: rollout percentage now lives in filters["groups"][N]["rollout_percentage"]
rollout_percentage = deprecate_field(models.IntegerField(null=True, blank=True))
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
- created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
+ created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, related_name="+")
created_at = models.DateTimeField(default=timezone.now)
updated_at = models.DateTimeField(null=True, auto_now=True)
deleted = models.BooleanField(default=False)
@@ -174,7 +174,9 @@ class FeatureFlag(FileSystemSyncMixin, ModelActivityMixin, RootTeamMixin, models
)
ensure_experience_continuity = models.BooleanField(default=False, null=True, blank=True)
- usage_dashboard = models.ForeignKey("dashboards.Dashboard", on_delete=models.SET_NULL, null=True, blank=True)
+ usage_dashboard = models.ForeignKey(
+ "dashboards.Dashboard", on_delete=models.SET_NULL, null=True, blank=True, related_name="+"
+ )
analytics_dashboards: models.ManyToManyField = models.ManyToManyField(
"dashboards.Dashboard",
through="FeatureFlagDashboards",
@@ -516,8 +518,8 @@ class FeatureFlagHashKeyOverride(models.Model):
# DO_NOTHING: Person/Team deletion handled manually via FeatureFlagHashKeyOverride.objects.filter(...).delete()
# in delete_bulky_postgres_data(). Django CASCADE doesn't work across separate databases.
# db_constraint=False: No database FK constraint - FeatureFlagHashKeyOverride may live in separate database
- person = models.ForeignKey("posthog.Person", on_delete=models.DO_NOTHING, db_constraint=False)
- team = models.ForeignKey("posthog.Team", on_delete=models.DO_NOTHING, db_constraint=False)
+ person = models.ForeignKey("posthog.Person", on_delete=models.DO_NOTHING, db_constraint=False, related_name="+")
+ team = models.ForeignKey("posthog.Team", on_delete=models.DO_NOTHING, db_constraint=False, related_name="+")
hash_key = models.CharField(max_length=400)
class Meta:
@@ -535,9 +537,9 @@ class FeatureFlagHashKeyOverride(models.Model):
# DEPRECATED: This model is no longer used, but it's not deleted to avoid downtime
class FeatureFlagOverride(models.Model):
feature_flag = models.ForeignKey("FeatureFlag", on_delete=models.CASCADE)
- user = models.ForeignKey("posthog.User", on_delete=models.CASCADE)
+ user = models.ForeignKey("posthog.User", on_delete=models.CASCADE, related_name="+")
override_value = models.JSONField()
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
class Meta:
constraints = [
@@ -626,7 +628,7 @@ def serialize_feature_flags(flags: list[FeatureFlag]) -> list[dict[str, Any]]:
class FeatureFlagDashboards(models.Model):
feature_flag = models.ForeignKey("FeatureFlag", on_delete=models.CASCADE)
- dashboard = models.ForeignKey("dashboards.Dashboard", on_delete=models.CASCADE)
+ dashboard = models.ForeignKey("dashboards.Dashboard", on_delete=models.CASCADE, related_name="+")
created_at = models.DateTimeField(auto_now_add=True, null=True)
updated_at = models.DateTimeField(auto_now=True, null=True)
diff --git a/products/feature_flags/backend/models/scheduled_change.py b/products/feature_flags/backend/models/scheduled_change.py
index 6e4b2c5fbfee..b553be5f9ef5 100644
--- a/products/feature_flags/backend/models/scheduled_change.py
+++ b/products/feature_flags/backend/models/scheduled_change.py
@@ -51,7 +51,7 @@ class ScheduledChange(RootTeamMixin, models.Model):
# UTC-wall-clock interpretation to avoid retroactively shifting any live schedule.
timezone = models.CharField(max_length=240, null=True, blank=True)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
# When a scheduled change would flip a policy-gated field (e.g. enabling a flag), a pending
# ChangeRequest is created at scheduling time and bound here. The Celery applier only applies
# the change once that CR is approved; if the fire window passes while still pending, the CR
@@ -64,7 +64,7 @@ class ScheduledChange(RootTeamMixin, models.Model):
related_name="scheduled_changes",
)
created_at = models.DateTimeField(auto_now_add=True)
- created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True)
+ created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, related_name="+")
updated_at = models.DateTimeField(auto_now=True)
class Meta:
diff --git a/products/feature_flags/backend/models/team_feature_flag_defaults_config.py b/products/feature_flags/backend/models/team_feature_flag_defaults_config.py
index d3253aaad066..945e58b9cbb9 100644
--- a/products/feature_flags/backend/models/team_feature_flag_defaults_config.py
+++ b/products/feature_flags/backend/models/team_feature_flag_defaults_config.py
@@ -8,7 +8,7 @@ logger = logging.getLogger(__name__)
class TeamFeatureFlagDefaultsConfig(models.Model):
- team = models.OneToOneField("posthog.Team", on_delete=models.CASCADE, primary_key=True)
+ team = models.OneToOneField("posthog.Team", on_delete=models.CASCADE, primary_key=True, related_name="+")
enabled = models.BooleanField(default=False)
diff --git a/products/field_notes/backend/migrations/0002_alter_fieldnote_team.py b/products/field_notes/backend/migrations/0002_alter_fieldnote_team.py
new file mode 100644
index 000000000000..b891681c39ce
--- /dev/null
+++ b/products/field_notes/backend/migrations/0002_alter_fieldnote_team.py
@@ -0,0 +1,23 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("field_notes", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="fieldnote",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/field_notes/backend/migrations/max_migration.txt b/products/field_notes/backend/migrations/max_migration.txt
index 6903cd5e3dc2..8d1de9ede1c6 100644
--- a/products/field_notes/backend/migrations/max_migration.txt
+++ b/products/field_notes/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_squash_2026_09_07_initial
+0002_alter_fieldnote_team
diff --git a/products/field_notes/backend/models.py b/products/field_notes/backend/models.py
index c18c576420af..fc8fcaff9228 100644
--- a/products/field_notes/backend/models.py
+++ b/products/field_notes/backend/models.py
@@ -19,7 +19,7 @@ class FieldNote(TeamScopedRootMixin, CreatedMetaFields, UpdatedMetaFields, UUIDT
RESOLVED = "resolved", "Resolved"
DISMISSED = "dismissed", "Dismissed"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
comment = models.TextField(help_text="The note the user wrote about the element.")
# Field named `field_note_status` (not `status`) to avoid a drf-spectacular enum-name collision.
diff --git a/products/growth/backend/migrations/0009_alter_enrichmentpromptconfig_created_by_and_more.py b/products/growth/backend/migrations/0009_alter_enrichmentpromptconfig_created_by_and_more.py
new file mode 100644
index 000000000000..f269a94499af
--- /dev/null
+++ b/products/growth/backend/migrations/0009_alter_enrichmentpromptconfig_created_by_and_more.py
@@ -0,0 +1,51 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("growth", "0008_icpscoringconfig"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="enrichmentpromptconfig",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="icpscoringconfig",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="productpushcampaign",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ]
diff --git a/products/growth/backend/migrations/max_migration.txt b/products/growth/backend/migrations/max_migration.txt
index 66801f8397cc..d30b9f4d3fdb 100644
--- a/products/growth/backend/migrations/max_migration.txt
+++ b/products/growth/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0008_icpscoringconfig
+0009_alter_enrichmentpromptconfig_created_by_and_more
diff --git a/products/growth/backend/models.py b/products/growth/backend/models.py
index 608ed003f184..3aafc7b459d9 100644
--- a/products/growth/backend/models.py
+++ b/products/growth/backend/models.py
@@ -37,11 +37,7 @@ class ProductPushCampaign(UUIDModel, UpdatedMetaFields):
db_constraint=False,
)
created_by = models.ForeignKey(
- "posthog.User",
- on_delete=models.SET_NULL,
- null=True,
- blank=True,
- db_constraint=False,
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
# A ProductKey value. Plain CharField (like ProductIntent.product_type) so the
@@ -178,11 +174,7 @@ class EnrichmentPromptConfig(UUIDModel):
# The version the batch runner computes; at most one active row per label (enforced below).
is_active = models.BooleanField(default=False)
created_by = models.ForeignKey(
- "posthog.User",
- on_delete=models.SET_NULL,
- null=True,
- blank=True,
- db_constraint=False,
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
created_at = models.DateTimeField(auto_now_add=True)
@@ -302,11 +294,7 @@ class IcpScoringConfig(UUIDModel):
# The row the scorer loads; at most one active row (enforced below).
is_active = models.BooleanField(default=False)
created_by = models.ForeignKey(
- "posthog.User",
- on_delete=models.SET_NULL,
- null=True,
- blank=True,
- db_constraint=False,
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
created_at = models.DateTimeField(auto_now_add=True)
diff --git a/products/links/backend/migrations/0002_alter_link_team.py b/products/links/backend/migrations/0002_alter_link_team.py
new file mode 100644
index 000000000000..dbeafbe29126
--- /dev/null
+++ b/products/links/backend/migrations/0002_alter_link_team.py
@@ -0,0 +1,24 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("links", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="link",
+ name="team",
+ field=models.ForeignKey(
+ help_text="Team that owns this link",
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/links/backend/migrations/max_migration.txt b/products/links/backend/migrations/max_migration.txt
index 6903cd5e3dc2..119cf468f398 100644
--- a/products/links/backend/migrations/max_migration.txt
+++ b/products/links/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_squash_2026_09_07_initial
+0002_alter_link_team
diff --git a/products/links/backend/models.py b/products/links/backend/models.py
index 8d23f3256bc0..3f2a603c8d0b 100644
--- a/products/links/backend/models.py
+++ b/products/links/backend/models.py
@@ -23,11 +23,7 @@ class Link(FileSystemSyncMixin, CreatedMetaFields, UpdatedMetaFields, UUIDTModel
short_code = models.CharField(
max_length=255, help_text="The unique code/path that identifies the short link, e.g. 'abc123'"
)
- team = models.ForeignKey(
- Team,
- on_delete=models.CASCADE,
- help_text="Team that owns this link",
- )
+ team = models.ForeignKey(Team, on_delete=models.CASCADE, help_text="Team that owns this link", related_name="+")
description = models.TextField(null=True, blank=True)
class Meta:
diff --git a/products/live_debugger/backend/migrations/0002_alter_livedebuggerbreakpoint_team.py b/products/live_debugger/backend/migrations/0002_alter_livedebuggerbreakpoint_team.py
new file mode 100644
index 000000000000..e3eef4126683
--- /dev/null
+++ b/products/live_debugger/backend/migrations/0002_alter_livedebuggerbreakpoint_team.py
@@ -0,0 +1,23 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("live_debugger", "0001_squash_2026_09_07_initial"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="livedebuggerbreakpoint",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/live_debugger/backend/migrations/max_migration.txt b/products/live_debugger/backend/migrations/max_migration.txt
index 6903cd5e3dc2..d579b58b8d52 100644
--- a/products/live_debugger/backend/migrations/max_migration.txt
+++ b/products/live_debugger/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_squash_2026_09_07_initial
+0002_alter_livedebuggerbreakpoint_team
diff --git a/products/live_debugger/backend/models.py b/products/live_debugger/backend/models.py
index 3a6714fee848..fe580908f988 100644
--- a/products/live_debugger/backend/models.py
+++ b/products/live_debugger/backend/models.py
@@ -44,7 +44,7 @@ class BreakpointHit:
class LiveDebuggerBreakpoint(UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
repository = models.TextField(null=True, blank=True) # Format: "owner/repo" (e.g., "PostHog/posthog")
filename = models.TextField()
line_number = models.PositiveIntegerField()
diff --git a/products/logs/backend/migrations/0025_alter_logsalertconfiguration_team_and_more.py b/products/logs/backend/migrations/0025_alter_logsalertconfiguration_team_and_more.py
new file mode 100644
index 000000000000..a330832cc26e
--- /dev/null
+++ b/products/logs/backend/migrations/0025_alter_logsalertconfiguration_team_and_more.py
@@ -0,0 +1,75 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("logs", "0024_logsmetricrule_source"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="logsalertconfiguration",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="logsexclusionrule",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="logsmetricrule",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="logsretentionrule",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="logsretentionrule",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="logsview",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/logs/backend/migrations/max_migration.txt b/products/logs/backend/migrations/max_migration.txt
index 85b529697da6..e6592b2c84b6 100644
--- a/products/logs/backend/migrations/max_migration.txt
+++ b/products/logs/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0024_logsmetricrule_source
+0025_alter_logsalertconfiguration_team_and_more
diff --git a/products/logs/backend/models.py b/products/logs/backend/models.py
index e0760b38accb..ce40d5a200c0 100644
--- a/products/logs/backend/models.py
+++ b/products/logs/backend/models.py
@@ -174,7 +174,7 @@ MAX_EVALUATION_PERIODS = 10
class LogsView(CreatedMetaFields, UpdatedMetaFields, UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
short_id = models.CharField(max_length=12, blank=True, default=generate_short_id)
name = models.CharField(max_length=400)
filters = models.JSONField(default=dict)
@@ -206,7 +206,7 @@ class LogsAlertConfiguration(ModelActivityMixin, CreatedMetaFields, UpdatedMetaF
ABOVE = "above", "Above"
BELOW = "below", "Below"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
name = models.CharField(max_length=255)
enabled = models.BooleanField(default=True)
@@ -430,7 +430,7 @@ class LogsMetricRule(ModelActivityMixin, TeamScopedRootMixin, CreatedMetaFields,
# db_constraint=False on the team/user FKs: posthog_team and posthog_user are hot tables,
# and creating an FK constraint against them locks the parent — see the hot-table section
# of safe-django-migrations.md. Enforcement is app-level (Django still cascades in the ORM).
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
"posthog.User", on_delete=models.SET_NULL, null=True, blank=True, related_name="+", db_constraint=False
)
@@ -475,7 +475,7 @@ class LogsExclusionRule(ModelActivityMixin, CreatedMetaFields, UpdatedMetaFields
PATH_DROP = "path_drop", "Path exclusion"
RATE_LIMIT = "rate_limit", "Rate limit"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
name = models.CharField(max_length=255)
enabled = models.BooleanField(default=False)
priority = models.PositiveIntegerField(
@@ -511,9 +511,9 @@ class LogsRetentionRule(ModelActivityMixin, CreatedMetaFields, UpdatedMetaFields
# db_constraint=False on the hot-table FKs (team, created_by) keeps the CreateModel migration
# lock-free — creating a real FK constraint would take a SHARE ROW EXCLUSIVE lock on the parent.
# Enforcement stays at the ORM level (cascade/set-null run through the Django collector).
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
name = models.CharField(max_length=255)
enabled = models.BooleanField(default=False)
diff --git a/products/managed_migrations/backend/migrations/0003_alter_batchimport_team.py b/products/managed_migrations/backend/migrations/0003_alter_batchimport_team.py
new file mode 100644
index 000000000000..a46eecfc0e0a
--- /dev/null
+++ b/products/managed_migrations/backend/migrations/0003_alter_batchimport_team.py
@@ -0,0 +1,23 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("managed_migrations", "0002_alter_batchimport_secrets_nullable"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="batchimport",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/managed_migrations/backend/migrations/max_migration.txt b/products/managed_migrations/backend/migrations/max_migration.txt
index 1c8a2e00b2a7..0e41e10acac8 100644
--- a/products/managed_migrations/backend/migrations/max_migration.txt
+++ b/products/managed_migrations/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0002_alter_batchimport_secrets_nullable
+0003_alter_batchimport_team
diff --git a/products/managed_migrations/backend/models/batch_imports.py b/products/managed_migrations/backend/models/batch_imports.py
index 654fedf5aad9..2f48da3329fa 100644
--- a/products/managed_migrations/backend/models/batch_imports.py
+++ b/products/managed_migrations/backend/models/batch_imports.py
@@ -43,7 +43,7 @@ class BatchImport(ModelActivityMixin, UUIDTModel):
PAUSED = "paused", "Paused"
RUNNING = "running", "Running"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
created_by_id = models.IntegerField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
diff --git a/products/managed_warehouse/backend/migrations/0006_alter_managedwarehousesourcejob_created_by.py b/products/managed_warehouse/backend/migrations/0006_alter_managedwarehousesourcejob_created_by.py
new file mode 100644
index 000000000000..71493156a501
--- /dev/null
+++ b/products/managed_warehouse/backend/migrations/0006_alter_managedwarehousesourcejob_created_by.py
@@ -0,0 +1,27 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("managed_warehouse", "0005_managedwarehouseviewtranslationjob_and_more"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="managedwarehousesourcejob",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ]
diff --git a/products/managed_warehouse/backend/migrations/max_migration.txt b/products/managed_warehouse/backend/migrations/max_migration.txt
index 6cebae7a5715..fd1b8dca9170 100644
--- a/products/managed_warehouse/backend/migrations/max_migration.txt
+++ b/products/managed_warehouse/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0005_managedwarehouseviewtranslationjob_and_more
+0006_alter_managedwarehousesourcejob_created_by
diff --git a/products/managed_warehouse/backend/models.py b/products/managed_warehouse/backend/models.py
index b177edb57e90..bd23b2689387 100644
--- a/products/managed_warehouse/backend/models.py
+++ b/products/managed_warehouse/backend/models.py
@@ -124,11 +124,7 @@ class ManagedWarehouseSourceJob(TeamScopedRootMixin, CreatedMetaFields, UpdatedM
db_constraint=False,
)
created_by = models.ForeignKey(
- "posthog.User",
- on_delete=models.SET_NULL,
- null=True,
- blank=True,
- db_constraint=False,
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
environment_id = models.BigIntegerField()
schema_id = models.UUIDField()
diff --git a/products/mcp_analytics/backend/migrations/0010_alter_mcpanalyticssubmission_team_and_more.py b/products/mcp_analytics/backend/migrations/0010_alter_mcpanalyticssubmission_team_and_more.py
new file mode 100644
index 000000000000..d37c61d59dc0
--- /dev/null
+++ b/products/mcp_analytics/backend/migrations/0010_alter_mcpanalyticssubmission_team_and_more.py
@@ -0,0 +1,41 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("mcp_analytics", "0009_mcpintentembeddingcache"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="mcpanalyticssubmission",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="mcpintentembeddingcache",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="mcpsession",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/mcp_analytics/backend/migrations/max_migration.txt b/products/mcp_analytics/backend/migrations/max_migration.txt
index a46117201e53..d1d7e2755215 100644
--- a/products/mcp_analytics/backend/migrations/max_migration.txt
+++ b/products/mcp_analytics/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0009_mcpintentembeddingcache
+0010_alter_mcpanalyticssubmission_team_and_more
diff --git a/products/mcp_analytics/backend/models.py b/products/mcp_analytics/backend/models.py
index d2ffaacf5f13..56482b426c2d 100644
--- a/products/mcp_analytics/backend/models.py
+++ b/products/mcp_analytics/backend/models.py
@@ -45,7 +45,7 @@ class MCPAnalyticsSubmission(UUIDModel):
DOCS = "docs", "Docs"
OTHER = "other", "Other"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True, related_name="+")
kind = models.CharField(max_length=32, choices=Kind)
@@ -85,7 +85,7 @@ class MCPIntentEmbeddingCache(UUIDModel, TeamScopedRootMixin):
in Postgres, so a typed Postgres array buys us nothing.
"""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
content_hash = models.CharField(max_length=64)
model = models.CharField(max_length=64)
embedding = models.BinaryField()
@@ -112,7 +112,7 @@ class MCPSession(UUIDModel, TeamScopedRootMixin):
# On-demand intent store keyed by (team, session_id). The session list itself
# is aggregated on the fly from $mcp_tool_call events (see logic.py); the
# backfill that once populated session_start/_end/duration/etc. is gone.
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
session_id = models.CharField(max_length=64)
intent = models.TextField(null=True, blank=True)
diff --git a/products/mcp_store/backend/migrations/0031_alter_mcpoauthstate_team_and_more.py b/products/mcp_store/backend/migrations/0031_alter_mcpoauthstate_team_and_more.py
new file mode 100644
index 000000000000..ff9eec013ccd
--- /dev/null
+++ b/products/mcp_store/backend/migrations/0031_alter_mcpoauthstate_team_and_more.py
@@ -0,0 +1,32 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("mcp_store", "0030_add_mcp_template_oauth_credentials_source"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="mcpoauthstate",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="mcpserverinstallation",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/mcp_store/backend/migrations/max_migration.txt b/products/mcp_store/backend/migrations/max_migration.txt
index 09dc87fcb15a..76aa8a804802 100644
--- a/products/mcp_store/backend/migrations/max_migration.txt
+++ b/products/mcp_store/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0030_add_mcp_template_oauth_credentials_source
+0031_alter_mcpoauthstate_team_and_more
diff --git a/products/mcp_store/backend/models.py b/products/mcp_store/backend/models.py
index 146b37600eb5..8f4ac8ccc389 100644
--- a/products/mcp_store/backend/models.py
+++ b/products/mcp_store/backend/models.py
@@ -188,7 +188,7 @@ class MCPServerTemplate(CreatedMetaFields, UpdatedMetaFields, UUIDModel):
class MCPServerInstallation(CreatedMetaFields, UpdatedMetaFields, UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
user = models.ForeignKey("posthog.User", on_delete=models.CASCADE, related_name="mcp_server_installations")
template = models.ForeignKey(
MCPServerTemplate, on_delete=models.SET_NULL, related_name="installations", null=True, blank=True
@@ -264,7 +264,7 @@ class MCPServerInstallationTool(CreatedMetaFields, UpdatedMetaFields, UUIDModel)
class MCPOAuthState(CreatedMetaFields, UpdatedMetaFields, UUIDModel):
token_hash = models.CharField(max_length=64, unique=True, db_index=True)
installation = models.ForeignKey(MCPServerInstallation, on_delete=models.CASCADE, related_name="oauth_states")
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
template = models.ForeignKey(
MCPServerTemplate, on_delete=models.CASCADE, related_name="oauth_states", null=True, blank=True
)
diff --git a/products/model_crossing_uses_baseline.txt b/products/model_crossing_uses_baseline.txt
index 9e6a80e763de..8112f59db6c2 100644
--- a/products/model_crossing_uses_baseline.txt
+++ b/products/model_crossing_uses_baseline.txt
@@ -24,10 +24,6 @@
#
# Regenerate: bin/hogli product:crossings --all --write-baseline
access_control.Role approvals.ApprovalPolicy.bypass_roles reverse-accessor(bypass_policies) 1
-access_control.Role conversations.TicketAssignment.role reverse-accessor(ticketassignment_set) 1
-access_control.Role error_tracking.ErrorTrackingAssignmentRule.role reverse-accessor(errortrackingassignmentrule_set) 1
-access_control.Role error_tracking.ErrorTrackingGroupingRule.role reverse-accessor(errortrackinggroupingrule_set) 1
-access_control.Role error_tracking.ErrorTrackingIssueAssignment.role reverse-accessor(errortrackingissueassignment_set) 1
access_control.Role posthog.Organization.default_role reverse-accessor(default_for_organizations) 1
actions.Action cdp.PluginConfig.match_action reverse-accessor(plugin_configs) 1
actions.Action posthog.TaggedItem.action reverse-accessor(tagged_items) 1
@@ -35,27 +31,19 @@ actions.Action surveys.Survey.actions reverse-accessor(survey_set) 1
approvals.ChangeRequest feature_flags.ScheduledChange.change_request reverse-accessor(scheduled_changes) 1
batch_exports.BatchExport cdp.HogFunction.batch_export reverse-accessor(hogfunction_set) 1
canvas.Canvas products.tasks.backend.logic.services.loop_runs get_model 1
-cohorts.Cohort error_tracking.ErrorTrackingIssueCohort.cohort reverse-accessor(errortrackingissuecohort_set) 1
cohorts.Cohort experiments.Experiment.exposure_cohort reverse-accessor(experiment_set) 1
conversations.Ticket posthog.TaggedItem.ticket reverse-accessor(tagged_items) 1
customer_analytics.Account notebooks.ResourceNotebook.account reverse-accessor(notebooks) 1
customer_analytics.Account posthog.TaggedItem.account reverse-accessor(tagged_items) 1
customer_analytics:backend/hogql_queries/ posthog.api.test.test_sharing drives(AccountsQuery) 1
-dashboards.Dashboard annotations.Annotation.dashboard reverse-accessor(annotation_set) 1
dashboards.Dashboard ee.DashboardPrivilege.dashboard reverse-accessor(privileges) 1
dashboards.Dashboard exports.ExportedAsset.dashboard reverse-accessor(exportedasset_set) 1
-dashboards.Dashboard exports.Subscription.dashboard reverse-accessor(subscription_set) 1
dashboards.Dashboard feature_flags.FeatureFlag.analytics_dashboards reverse-accessor(analytics_dashboards) 1
-dashboards.Dashboard feature_flags.FeatureFlag.usage_dashboard reverse-accessor(featureflag_set) 1
-dashboards.Dashboard feature_flags.FeatureFlagDashboards.dashboard reverse-accessor(featureflagdashboards_set) 1
-dashboards.Dashboard posthog.GroupTypeMapping.detail_dashboard reverse-accessor(grouptypemapping_set) 1
dashboards.Dashboard posthog.SharingConfiguration.dashboard reverse-accessor(sharingconfiguration_set) 1
dashboards.Dashboard posthog.TaggedItem.dashboard reverse-accessor(tagged_items) 1
dashboards.Dashboard posthog.Team.primary_dashboard reverse-accessor(primary_dashboard_teams) 1
-dashboards.Dashboard posthog.UserScenePersonalisation.dashboard reverse-accessor(userscenepersonalisation_set) 1
dashboards.Dashboard product_analytics.Insight.dashboard reverse-accessor(items) 1
dashboards.Dashboard product_analytics.Insight.dive_dashboard reverse-accessor(insight_set) 1
-data_modeling.DataWarehouseSavedQuery data_tools.DataWarehouseViewLink.saved_query reverse-accessor(datawarehouseviewlink_set) 1
data_modeling.DataWarehouseSavedQuery endpoints.EndpointVersion.saved_query reverse-accessor(endpoint_versions) 1
data_modeling.DataWarehouseSavedQuery products.customer_analytics.backend.facade.api get_model 5
data_tools.DataWarehouseSavedQueryFolder data_modeling.DataWarehouseSavedQuery.folder reverse-accessor(saved_queries) 1
@@ -99,29 +87,16 @@ feature_flags.FeatureFlag surveys.Survey.linked_flag reverse-accessor(surveys_li
feature_flags.FeatureFlag surveys.Survey.targeting_flag reverse-accessor(surveys_targeting_flag) 1
metrics:backend/hogql_queries/ posthog.tasks.alerts.test.test_metrics_alerts drives(MetricsQuery) 1
notebooks.Notebook posthog.SharingConfiguration.notebook reverse-accessor(sharing_configurations) 1
-posthog.Comment conversations.EmailMessageMapping.comment reverse-accessor(emailmessagemapping_set) 1
-posthog.Comment conversations.EmailOutboxMessage.comment reverse-accessor(emailoutboxmessage) 1
posthog.Comment conversations.EmailThreadMessage.comment reverse-accessor(email_thread_message) 1
-posthog.Comment conversations.GithubCommentMapping.comment reverse-accessor(githubcommentmapping_set) 1
posthog.CoreEvent marketing_analytics.MarketingAnalyticsGoalMapping.core_event reverse-accessor(marketing_goal_mappings) 1
-posthog.DataColorTheme dashboards.Dashboard.data_color_theme reverse-accessor(dashboard_set) 1
posthog.Event actions.Action.events reverse-accessor(action_set) 1
-posthog.Integration batch_exports.BatchExportDestination.integration reverse-accessor(batchexportdestination_set) 1
-posthog.Integration data_modeling.GitHubSyncConfig.integration reverse-accessor(githubsyncconfig_set) 1
-posthog.Integration error_tracking.ErrorTrackingExternalReference.integration reverse-accessor(errortrackingexternalreference_set) 1
-posthog.Integration exports.Subscription.integration reverse-accessor(subscription_set) 1
posthog.Integration slack_app.SlackSettings.default_integration reverse-accessor(slack_settings_as_default) 1
posthog.Integration slack_app.SlackThreadTaskMapping.integration reverse-accessor(slack_thread_task_mappings) 1
posthog.Integration slack_app.SlackUserProfileCache.integration reverse-accessor(slack_user_profile_cache) 1
posthog.Integration tasks.SandboxSnapshot.integration reverse-accessor(snapshots) 1
-posthog.Integration tasks.Task.github_integration reverse-accessor(task_set) 1
-posthog.Integration warehouse_sources.ExternalDataDestination.integration reverse-accessor(externaldatadestination_set) 1
posthog.Organization access_control.OrganizationResourceAccess.organization reverse-accessor(resource_access) 1
posthog.Organization access_control.Role.organization reverse-accessor(roles) 1
posthog.Organization access_control.RoleExternalReference.organization reverse-accessor(role_external_references) 1
-posthog.Organization annotations.Annotation.organization reverse-accessor(annotation_set) 1
-posthog.Organization approvals.ApprovalPolicy.organization reverse-accessor(approvalpolicy_set) 1
-posthog.Organization approvals.ChangeRequest.organization reverse-accessor(changerequest_set) 1
posthog.Organization cdp.Plugin.has_private_access reverse-accessor(plugin_set) 1
posthog.Organization cdp.Plugin.organization reverse-accessor(plugins) 1
posthog.Organization growth.EnrichmentLabelResult.organization reverse-accessor(enrichment_label_results) 1
@@ -132,208 +107,58 @@ posthog.Organization growth.ProductPushCampaign.organization reverse-accessor(pr
posthog.Organization legal_documents.LegalDocument.organization reverse-accessor(legal_documents) 1
posthog.Organization managed_warehouse.DuckgresServer.organization reverse-accessor(duckgres_server) 1
posthog.Organization managed_warehouse.ManagedWarehouseSourceLifecycle.organization reverse-accessor(managed_warehouse_source_lifecycle) 1
-posthog.Organization notifications.NotificationEvent.organization reverse-accessor(notificationevent_set) 1
-posthog.Organization reminders.Reminder.organization reverse-accessor(reminder_set) 1
posthog.Organization replay_vision.ReplayObservationUsage.organization reverse-accessor(replay_observation_usage) 1
-posthog.Organization tasks.DesktopBetaTermsAcceptance.organization reverse-accessor(desktopbetatermsacceptance) 1
posthog.OrganizationMembership access_control.AccessControl.organization_member reverse-accessor(access_controls) 1
posthog.OrganizationMembership access_control.PropertyAccessControl.organization_member reverse-accessor(property_access_controls) 1
posthog.OrganizationMembership access_control.RoleMembership.organization_member reverse-accessor(role_memberships) 1
-posthog.Person cohorts.Cohort.people reverse-accessor(cohort_set) 1
-posthog.Person cohorts.CohortPeople.person reverse-accessor(cohortpeople_set) 1
-posthog.Person feature_flags.FeatureFlagHashKeyOverride.person reverse-accessor(featureflaghashkeyoverride_set) 1
posthog.Project actions.Action.project reverse-accessor(action_set) 1
-posthog.Project event_definitions.EventDefinition.project reverse-accessor(eventdefinition_set) 1
-posthog.Project event_definitions.EventProperty.project reverse-accessor(eventproperty_set) 1
-posthog.Project event_definitions.PropertyDefinition.project reverse-accessor(propertydefinition_set) 1
-posthog.Project event_definitions.SchemaPropertyGroup.project reverse-accessor(schemapropertygroup_set) 1
posthog.Team access_control.AccessControl.team reverse-accessor(access_controls) 1
posthog.Team access_control.PropertyAccessControl.team reverse-accessor(property_access_controls) 1
posthog.Team actions.Action.team reverse-accessor(action_set) 1
-posthog.Team ai_observability.AIObservabilityChecklistItemState.team reverse-accessor(aiobservabilitychecklistitemstate_set) 1
posthog.Team ai_observability.ClusteringConfig.team reverse-accessor(clustering_config) 1
posthog.Team ai_observability.ClusteringJob.team reverse-accessor(clustering_jobs) 1
-posthog.Team ai_observability.Dataset.team reverse-accessor(dataset_set) 1
-posthog.Team ai_observability.DatasetItem.team reverse-accessor(datasetitem_set) 1
-posthog.Team ai_observability.DatasetItemVersion.team reverse-accessor(datasetitemversion_set) 1
-posthog.Team ai_observability.DatasetRevision.team reverse-accessor(datasetrevision_set) 1
-posthog.Team ai_observability.Evaluation.team reverse-accessor(evaluation_set) 1
posthog.Team ai_observability.EvaluationConfig.team reverse-accessor(evaluation_config) 1
-posthog.Team ai_observability.EvaluationDirectory.team reverse-accessor(evaluationdirectory_set) 1
-posthog.Team ai_observability.EvaluationReport.team reverse-accessor(evaluationreport_set) 1
-posthog.Team ai_observability.LLMModelConfiguration.team reverse-accessor(llmmodelconfiguration_set) 1
-posthog.Team ai_observability.LLMPrompt.team reverse-accessor(llmprompt_set) 1
-posthog.Team ai_observability.LLMPromptLabel.team reverse-accessor(llmpromptlabel_set) 1
-posthog.Team ai_observability.LLMProviderKey.team reverse-accessor(llmproviderkey_set) 1
-posthog.Team ai_observability.LLMTraceSummary.team reverse-accessor(llmtracesummary_set) 1
-posthog.Team ai_observability.ParserRecipe.team reverse-accessor(parserrecipe_set) 1
-posthog.Team ai_observability.ReviewQueue.team reverse-accessor(reviewqueue_set) 1
-posthog.Team ai_observability.ReviewQueueItem.team reverse-accessor(reviewqueueitem_set) 1
-posthog.Team ai_observability.ScoreDefinition.team reverse-accessor(scoredefinition_set) 1
-posthog.Team ai_observability.Tagger.team reverse-accessor(tagger_set) 1
-posthog.Team ai_observability.TraceReview.team reverse-accessor(tracereview_set) 1
-posthog.Team ai_observability.TraceReviewScore.team reverse-accessor(tracereviewscore_set) 1
-posthog.Team alerts.Alert.team reverse-accessor(alert_set) 1
posthog.Team alerts.AlertConfiguration.team reverse-accessor(alertconfiguration_set) 1
-posthog.Team alerts.Threshold.team reverse-accessor(threshold_set) 1
-posthog.Team analytics_platform.PreaggregationJob.team reverse-accessor(preaggregationjob_set) 1
-posthog.Team annotations.Annotation.team reverse-accessor(annotation_set) 1
-posthog.Team approvals.ApprovalPolicy.team reverse-accessor(approvalpolicy_set) 1
-posthog.Team approvals.ChangeRequest.team reverse-accessor(changerequest_set) 1
-posthog.Team batch_exports.BatchExport.team reverse-accessor(batchexport_set) 1
posthog.Team batch_exports.BatchExportBackfill.team reverse-accessor(batchexportbackfill_set) 1
-posthog.Team batch_exports.BatchExportFileDownload.team reverse-accessor(batchexportfiledownload_set) 1
-posthog.Team batch_exports.BatchExportOnDemand.team reverse-accessor(batchexportondemand_set) 1
-posthog.Team batch_exports.BatchExportSource.team reverse-accessor(batchexportsource_set) 1
posthog.Team business_knowledge.KnowledgeGapSuggestion.team reverse-accessor(business_knowledge_gap_suggestions) 1
posthog.Team business_knowledge.KnowledgeSource.team reverse-accessor(business_knowledge_sources) 1
-posthog.Team canvas.Canvas.team reverse-accessor(canvas_set) 1
-posthog.Team canvas.CanvasBuild.team reverse-accessor(canvasbuild_set) 1
-posthog.Team canvas.CanvasHomePreference.team reverse-accessor(canvashomepreference_set) 1
-posthog.Team canvas.CanvasSourceVersion.team reverse-accessor(canvassourceversion_set) 1
-posthog.Team canvas.CanvasState.team reverse-accessor(canvasstate_set) 1
posthog.Team cdp.HogFunction.team reverse-accessor(hogfunction_set) 1
posthog.Team cdp.HogFunctionRevision.team reverse-accessor(hogfunctionrevision_set) 1
posthog.Team cdp.Hook.team reverse-accessor(rest_hooks) 1
posthog.Team cdp.PluginAttachment.team reverse-accessor(pluginattachment_set) 1
posthog.Team cdp.PluginConfig.team reverse-accessor(pluginconfig_set) 1
posthog.Team cohorts.Cohort.team reverse-accessor(cohort_set) 1
-posthog.Team cohorts.CohortCalculationHistory.team reverse-accessor(cohortcalculationhistory_set) 1
posthog.Team conversations.ConversationRestoreToken.team reverse-accessor(conversation_restore_tokens) 1
posthog.Team conversations.EmailChannel.team reverse-accessor(email_channels) 1
-posthog.Team conversations.EmailChannelSetup.team reverse-accessor(emailchannelsetup_set) 1
-posthog.Team conversations.EmailMessageMapping.team reverse-accessor(emailmessagemapping_set) 1
-posthog.Team conversations.EmailOutboxMessage.team reverse-accessor(emailoutboxmessage_set) 1
-posthog.Team conversations.EmailThread.team reverse-accessor(emailthread_set) 1
-posthog.Team conversations.EmailThreadAccountLink.team reverse-accessor(emailthreadaccountlink_set) 1
-posthog.Team conversations.EmailThreadMessage.team reverse-accessor(emailthreadmessage_set) 1
-posthog.Team conversations.EmailThreadParticipant.team reverse-accessor(emailthreadparticipant_set) 1
-posthog.Team conversations.GithubCommentMapping.team reverse-accessor(githubcommentmapping_set) 1
posthog.Team conversations.SigningSecret.team reverse-accessor(conversations_signing_secret) 1
posthog.Team conversations.TeamConversationsSlackConfig.team reverse-accessor(teamconversationsslackconfig) 1
-posthog.Team conversations.TeamConversationsTeamsChannelSync.team reverse-accessor(teamconversationsteamschannelsync_set) 1
posthog.Team conversations.TeamConversationsTeamsConfig.team reverse-accessor(teamconversationsteamsconfig) 1
-posthog.Team conversations.Ticket.team reverse-accessor(ticket_set) 1
-posthog.Team conversations.TicketView.team reverse-accessor(ticketview_set) 1
-posthog.Team conversations.TicketViewFavorite.team reverse-accessor(ticketviewfavorite_set) 1
-posthog.Team conversations.ZendeskImportJob.team reverse-accessor(zendeskimportjob_set) 1
-posthog.Team customer_analytics.Account.team reverse-accessor(account_set) 1
-posthog.Team customer_analytics.AccountChannelSummary.team reverse-accessor(accountchannelsummary_set) 1
-posthog.Team customer_analytics.AccountRelationship.team reverse-accessor(accountrelationship_set) 1
-posthog.Team customer_analytics.AccountRelationshipDefinition.team reverse-accessor(accountrelationshipdefinition_set) 1
-posthog.Team customer_analytics.AccountTrackRuleRun.team reverse-accessor(accounttrackrulerun_set) 1
-posthog.Team customer_analytics.Announcement.team reverse-accessor(announcement_set) 1
-posthog.Team customer_analytics.AnnouncementDelivery.team reverse-accessor(announcementdelivery_set) 1
-posthog.Team customer_analytics.CustomPropertyDefinition.team reverse-accessor(custompropertydefinition_set) 1
-posthog.Team customer_analytics.CustomPropertySource.team reverse-accessor(custompropertysource_set) 1
-posthog.Team customer_analytics.CustomPropertySyncRun.team reverse-accessor(custompropertysyncrun_set) 1
-posthog.Team customer_analytics.CustomPropertyValue.team reverse-accessor(custompropertyvalue_set) 1
-posthog.Team customer_analytics.CustomerJourney.team reverse-accessor(customerjourney_set) 1
-posthog.Team customer_analytics.CustomerProfileConfig.team reverse-accessor(customerprofileconfig_set) 1
-posthog.Team customer_analytics.EventStreamMember.team reverse-accessor(eventstreammember_set) 1
-posthog.Team customer_analytics.FeatureRequest.team reverse-accessor(featurerequest_set) 1
-posthog.Team customer_analytics.FeatureRequestAccountLink.team reverse-accessor(featurerequestaccountlink_set) 1
-posthog.Team customer_analytics.FeatureRequestEvidence.team reverse-accessor(featurerequestevidence_set) 1
-posthog.Team customer_analytics.FeatureRequestHistory.team reverse-accessor(featurerequesthistory_set) 1
-posthog.Team customer_analytics.FeatureRequestProductArea.team reverse-accessor(featurerequestproductarea_set) 1
-posthog.Team customer_analytics.FeatureRequestProductAreaLink.team reverse-accessor(featurerequestproductarealink_set) 1
-posthog.Team customer_analytics.Meeting.team reverse-accessor(meeting_set) 1
-posthog.Team customer_analytics.MeetingParticipant.team reverse-accessor(meetingparticipant_set) 1
posthog.Team customer_analytics.TeamCustomerAnalyticsConfig.team reverse-accessor(teamcustomeranalyticsconfig) 1
-posthog.Team dashboards.ButtonTile.team reverse-accessor(buttontile_set) 1
posthog.Team dashboards.Dashboard.team reverse-accessor(dashboard_set) 1
-posthog.Team dashboards.DashboardTemplate.team reverse-accessor(dashboardtemplate_set) 1
-posthog.Team dashboards.DashboardTile.team reverse-accessor(dashboardtile_set) 1
-posthog.Team dashboards.DashboardWidget.team reverse-accessor(dashboardwidget_set) 1
posthog.Team dashboards.Text.team reverse-accessor(text_set) 1
-posthog.Team data_catalog.Metric.team reverse-accessor(metric_set) 1
-posthog.Team data_catalog.RelationshipProposal.team reverse-accessor(relationshipproposal_set) 1
-posthog.Team data_catalog.TableCertification.team reverse-accessor(tablecertification_set) 1
-posthog.Team data_modeling.DAG.team reverse-accessor(dag_set) 1
posthog.Team data_modeling.DataModelingJob.team reverse-accessor(datamodelingjob_set) 1
-posthog.Team data_modeling.DataWarehouseManagedViewSet.team reverse-accessor(datawarehousemanagedviewset_set) 1
-posthog.Team data_modeling.DataWarehouseModelPath.team reverse-accessor(datawarehousemodelpath_set) 1
-posthog.Team data_modeling.DataWarehouseSavedQuery.team reverse-accessor(datawarehousesavedquery_set) 1
-posthog.Team data_modeling.DataWarehouseSavedQueryColumnAnnotation.team reverse-accessor(datawarehousesavedquerycolumnannotation_set) 1
-posthog.Team data_modeling.DataWarehouseSavedQueryDraft.team reverse-accessor(datawarehousesavedquerydraft_set) 1
-posthog.Team data_modeling.Edge.team reverse-accessor(edge_set) 1
posthog.Team data_modeling.GitHubSyncConfig.team reverse-accessor(githubsyncconfig) 1
-posthog.Team data_modeling.GitHubSyncPlan.team reverse-accessor(githubsyncplan_set) 1
-posthog.Team data_modeling.GitHubSyncedModel.team reverse-accessor(githubsyncedmodel_set) 1
-posthog.Team data_modeling.Node.team reverse-accessor(node_set) 1
-posthog.Team data_quality.DataQualityCheck.team reverse-accessor(dataqualitycheck_set) 1
-posthog.Team data_quality.DataQualityCheckRun.team reverse-accessor(dataqualitycheckrun_set) 1
-posthog.Team data_quality.DataQualitySuiteRun.team reverse-accessor(dataqualitysuiterun_set) 1
-posthog.Team data_quality.TeamDataQualityConfig.team reverse-accessor(teamdataqualityconfig) 1
-posthog.Team data_tools.DataWarehouseExpression.team reverse-accessor(datawarehouseexpression_set) 1
-posthog.Team data_tools.DataWarehouseJoin.team reverse-accessor(datawarehousejoin_set) 1
-posthog.Team data_tools.DataWarehouseSavedQueryFolder.team reverse-accessor(datawarehousesavedqueryfolder_set) 1
-posthog.Team data_tools.DataWarehouseViewLink.team reverse-accessor(datawarehouseviewlink_set) 1
-posthog.Team data_tools.QueryTabState.team reverse-accessor(querytabstate_set) 1
-posthog.Team data_warehouse.ManagedWarehouseBackfillPartition.team reverse-accessor(managedwarehousebackfillpartition_set) 1
posthog.Team data_warehouse.TeamDataWarehouseConfig.team reverse-accessor(teamdatawarehouseconfig) 1
posthog.Team early_access_features.EarlyAccessFeature.team reverse-accessor(features) 1
-posthog.Team endpoints.Endpoint.team reverse-accessor(endpoint_set) 1
-posthog.Team endpoints.EndpointVersion.team reverse-accessor(endpointversion_set) 1
-posthog.Team error_tracking.ErrorTrackingAssignmentRule.team reverse-accessor(errortrackingassignmentrule_set) 1
-posthog.Team error_tracking.ErrorTrackingAutoCaptureControls.team reverse-accessor(errortrackingautocapturecontrols_set) 1
-posthog.Team error_tracking.ErrorTrackingBypassRule.team reverse-accessor(errortrackingbypassrule_set) 1
-posthog.Team error_tracking.ErrorTrackingGroup.team reverse-accessor(errortrackinggroup_set) 1
-posthog.Team error_tracking.ErrorTrackingGroupingRule.team reverse-accessor(errortrackinggroupingrule_set) 1
-posthog.Team error_tracking.ErrorTrackingIssue.team reverse-accessor(errortrackingissue_set) 1
-posthog.Team error_tracking.ErrorTrackingIssueAssignment.team reverse-accessor(errortrackingissueassignment_set) 1
-posthog.Team error_tracking.ErrorTrackingIssueFingerprint.team reverse-accessor(errortrackingissuefingerprint_set) 1
-posthog.Team error_tracking.ErrorTrackingIssueFingerprintV2.team reverse-accessor(errortrackingissuefingerprintv2_set) 1
posthog.Team error_tracking.ErrorTrackingRecommendation.team reverse-accessor(error_tracking_recommendations) 1
-posthog.Team error_tracking.ErrorTrackingRelease.team reverse-accessor(errortrackingrelease_set) 1
posthog.Team error_tracking.ErrorTrackingSettings.team reverse-accessor(error_tracking_settings) 1
-posthog.Team error_tracking.ErrorTrackingSeverityRule.team reverse-accessor(errortrackingseverityrule_set) 1
posthog.Team error_tracking.ErrorTrackingSpikeDetectionConfig.team reverse-accessor(error_tracking_spike_detection_config) 1
-posthog.Team error_tracking.ErrorTrackingSpikeEvent.team reverse-accessor(errortrackingspikeevent_set) 1
posthog.Team error_tracking.ErrorTrackingStackFrame.team reverse-accessor(errortrackingstackframe_set) 1
-posthog.Team error_tracking.ErrorTrackingSuppressionRule.team reverse-accessor(errortrackingsuppressionrule_set) 1
-posthog.Team error_tracking.ErrorTrackingSymbolSet.team reverse-accessor(errortrackingsymbolset_set) 1
posthog.Team event_definitions.EventDefinition.team reverse-accessor(event_definitions) 1
-posthog.Team event_definitions.EventProperty.team reverse-accessor(eventproperty_set) 1
posthog.Team event_definitions.PropertyDefinition.team reverse-accessor(property_definitions) 1
posthog.Team event_definitions.SchemaPropertyGroup.team reverse-accessor(schema_property_groups) 1
posthog.Team experiments.Experiment.team reverse-accessor(experiment_set) 1
-posthog.Team experiments.ExperimentHoldout.team reverse-accessor(experimentholdout_set) 1
-posthog.Team experiments.ExperimentMetricsRecalculation.team reverse-accessor(experimentmetricsrecalculation_set) 1
-posthog.Team experiments.ExperimentSavedMetric.team reverse-accessor(experimentsavedmetric_set) 1
-posthog.Team experiments.ExperimentTimeseriesRecalculation.team reverse-accessor(experimenttimeseriesrecalculation_set) 1
posthog.Team experiments.TeamExperimentsConfig.team reverse-accessor(teamexperimentsconfig) 1
posthog.Team exports.ExportedAsset.team reverse-accessor(exportedasset_set) 1
-posthog.Team exports.Subscription.team reverse-accessor(subscription_set) 1
-posthog.Team exports.SubscriptionDelivery.team reverse-accessor(subscriptiondelivery_set) 1
posthog.Team feature_flags.EvaluationContext.team reverse-accessor(evaluation_context_set) 1
-posthog.Team feature_flags.FeatureFlag.team reverse-accessor(featureflag_set) 1
-posthog.Team feature_flags.FeatureFlagHashKeyOverride.team reverse-accessor(featureflaghashkeyoverride_set) 1
-posthog.Team feature_flags.FeatureFlagOverride.team reverse-accessor(featureflagoverride_set) 1
-posthog.Team feature_flags.ScheduledChange.team reverse-accessor(scheduledchange_set) 1
posthog.Team feature_flags.TeamDefaultEvaluationContext.team reverse-accessor(default_evaluation_context_set) 1
-posthog.Team feature_flags.TeamFeatureFlagDefaultsConfig.team reverse-accessor(teamfeatureflagdefaultsconfig) 1
posthog.Team feature_flags.TeamFeatureFlagsConfig.team reverse-accessor(teamfeatureflagsconfig) 1
-posthog.Team field_notes.FieldNote.team reverse-accessor(fieldnote_set) 1
-posthog.Team links.Link.team reverse-accessor(link_set) 1
-posthog.Team live_debugger.LiveDebuggerBreakpoint.team reverse-accessor(livedebuggerbreakpoint_set) 1
-posthog.Team logs.LogsAlertConfiguration.team reverse-accessor(logsalertconfiguration_set) 1
-posthog.Team logs.LogsExclusionRule.team reverse-accessor(logsexclusionrule_set) 1
-posthog.Team logs.LogsMetricRule.team reverse-accessor(logsmetricrule_set) 1
-posthog.Team logs.LogsRetentionRule.team reverse-accessor(logsretentionrule_set) 1
-posthog.Team logs.LogsView.team reverse-accessor(logsview_set) 1
posthog.Team logs.TeamLogsConfig.team reverse-accessor(teamlogsconfig) 1
-posthog.Team managed_migrations.BatchImport.team reverse-accessor(batchimport_set) 1
posthog.Team managed_warehouse.ManagedWarehouseSourceJob.team reverse-accessor(managed_warehouse_source_jobs) 1
posthog.Team marketing_analytics.MarketingAnalyticsGoalMapping.team reverse-accessor(marketing_analytics_goal_mappings) 1
-posthog.Team mcp_analytics.MCPAnalyticsSubmission.team reverse-accessor(mcpanalyticssubmission_set) 1
posthog.Team mcp_analytics.MCPIntentClusterSnapshot.team reverse-accessor(mcp_intent_cluster_snapshot) 1
-posthog.Team mcp_analytics.MCPIntentEmbeddingCache.team reverse-accessor(mcpintentembeddingcache_set) 1
-posthog.Team mcp_analytics.MCPSession.team reverse-accessor(mcpsession_set) 1
posthog.Team mcp_store.MCPGatewayServer.team reverse-accessor(gateway_servers) 1
-posthog.Team mcp_store.MCPOAuthState.team reverse-accessor(mcpoauthstate_set) 1
posthog.Team mcp_store.MCPOrgRule.team reverse-accessor(org_rules) 1
-posthog.Team mcp_store.MCPServerInstallation.team reverse-accessor(mcpserverinstallation_set) 1
posthog.Team mcp_store.MCPServiceAccount.team reverse-accessor(mcp_service_accounts) 1
posthog.Team mcp_store.TeamMCPGatewayConfig.team reverse-accessor(mcp_gateway_config) 1
posthog.Team messaging.MessageCategory.team reverse-accessor(messagecategory_set) 1
@@ -341,31 +166,17 @@ posthog.Team messaging.MessageRecipientPreference.team reverse-accessor(messager
posthog.Team messaging.MessageSuppression.team reverse-accessor(messagesuppression_set) 1
posthog.Team messaging.MessageTemplate.team reverse-accessor(messagetemplate_set) 1
posthog.Team messaging.OptOutSyncConfig.team reverse-accessor(optoutsyncconfig) 1
-posthog.Team notebooks.KernelRuntime.team reverse-accessor(kernelruntime_set) 1
-posthog.Team notebooks.Notebook.team reverse-accessor(notebook_set) 1
-posthog.Team notebooks.NotebookNodeRun.team reverse-accessor(notebooknoderun_set) 1
-posthog.Team notifications.NotificationEvent.team reverse-accessor(notificationevent_set) 1
-posthog.Team posthog_ai.AgentArtifact.team reverse-accessor(agentartifact_set) 1
posthog.Team posthog_ai.AgentMemory.team reverse-accessor(agent_memories) 1
-posthog.Team posthog_ai.Conversation.team reverse-accessor(conversation_set) 1
posthog.Team posthog_ai.CoreMemory.team reverse-accessor(corememory) 1
posthog.Team product_analytics.Insight.team reverse-accessor(insight_set) 1
-posthog.Team product_analytics.InsightVariable.team reverse-accessor(insightvariable_set) 1
posthog.Team product_analytics.InsightViewed.team reverse-accessor(insightviewed_set) 1
posthog.Team product_tours.ProductTour.team reverse-accessor(product_tours) 1
posthog.Team pulse.BriefConfig.team reverse-accessor(briefconfig_set) 1
posthog.Team pulse.Opportunity.team reverse-accessor(opportunity_set) 1
posthog.Team pulse.ProductBrief.team reverse-accessor(productbrief_set) 1
posthog.Team pulse.ResourceLink.team reverse-accessor(resourcelink_set) 1
-posthog.Team reminders.Reminder.team reverse-accessor(reminder_set) 1
posthog.Team replay.ExportedRecording.team reverse-accessor(exported_recordings) 1
-posthog.Team signals.SignalEmissionRecord.team reverse-accessor(signalemissionrecord_set) 1
posthog.Team signals.SignalProjectProfile.team reverse-accessor(signal_project_profiles) 1
-posthog.Team signals.SignalReport.team reverse-accessor(signalreport_set) 1
-posthog.Team signals.SignalReportAction.team reverse-accessor(signalreportaction_set) 1
-posthog.Team signals.SignalReportArtefact.team reverse-accessor(signalreportartefact_set) 1
-posthog.Team signals.SignalReportRefund.team reverse-accessor(signalreportrefund_set) 1
-posthog.Team signals.SignalReportTask.team reverse-accessor(signalreporttask_set) 1
posthog.Team signals.SignalRepositoryAreaActivity.team reverse-accessor(signal_repo_area_activities) 1
posthog.Team signals.SignalScoutConfig.team reverse-accessor(signal_scout_configs) 1
posthog.Team signals.SignalScoutEmission.team reverse-accessor(signal_scout_emissions) 1
@@ -374,39 +185,10 @@ posthog.Team signals.SignalScoutRun.team reverse-accessor(signal_scout_runs) 1
posthog.Team signals.SignalScratchpad.team reverse-accessor(signal_scratchpads) 1
posthog.Team signals.SignalSourceConfig.team reverse-accessor(signal_source_configs) 1
posthog.Team signals.SignalTeamConfig.team reverse-accessor(signal_team_config) 1
-posthog.Team skills.LLMSkill.team reverse-accessor(llmskill_set) 1
posthog.Team slack_app.SlackThreadTaskMapping.team reverse-accessor(slack_thread_task_mappings) 1
-posthog.Team streamlit_apps.StreamlitApp.team reverse-accessor(streamlitapp_set) 1
posthog.Team surveys.Survey.team reverse-accessor(surveys) 1
posthog.Team surveys.SurveyResponseArchive.team reverse-accessor(survey_response_archives) 1
-posthog.Team tasks.SandboxEnvironment.team reverse-accessor(sandboxenvironment_set) 1
-posthog.Team tasks.Task.team reverse-accessor(task_set) 1
-posthog.Team tasks.TaskRun.team reverse-accessor(taskrun_set) 1
-posthog.Team tasks.TaskWorkflowDispatch.team reverse-accessor(taskworkflowdispatch_set) 1
-posthog.Team tracing.TeamTracingConfig.team reverse-accessor(teamtracingconfig) 1
-posthog.Team tracing.TracingView.team reverse-accessor(tracingview_set) 1
-posthog.Team user_interviews.IntervieweeContext.team reverse-accessor(intervieweecontext_set) 1
-posthog.Team user_interviews.UserInterview.team reverse-accessor(userinterview_set) 1
-posthog.Team user_interviews.UserInterviewTopic.team reverse-accessor(userinterviewtopic_set) 1
-posthog.Team warehouse_sources.CustomOAuth2Integration.team reverse-accessor(customoauth2integration_set) 1
-posthog.Team warehouse_sources.DataWarehouseCredential.team reverse-accessor(datawarehousecredential_set) 1
-posthog.Team warehouse_sources.DataWarehouseTable.team reverse-accessor(datawarehousetable_set) 1
-posthog.Team warehouse_sources.ExternalDataDestination.team reverse-accessor(externaldatadestination_set) 1
-posthog.Team warehouse_sources.ExternalDataJob.team reverse-accessor(externaldatajob_set) 1
posthog.Team warehouse_sources.ExternalDataSchema.team reverse-accessor(externaldataschema_set) 1
-posthog.Team warehouse_sources.ExternalDataSchemaDestination.team reverse-accessor(externaldataschemadestination_set) 1
-posthog.Team warehouse_sources.ExternalDataSchemaOOMEvent.team reverse-accessor(externaldataschemaoomevent_set) 1
-posthog.Team warehouse_sources.ExternalDataSource.team reverse-accessor(externaldatasource_set) 1
-posthog.Team warehouse_sources.ExternalDataSourceDestination.team reverse-accessor(externaldatasourcedestination_set) 1
-posthog.Team warehouse_sources.PendingSourceCredential.team reverse-accessor(pendingsourcecredential_set) 1
-posthog.Team warehouse_sources.WarehouseColumnAnnotation.team reverse-accessor(warehousecolumnannotation_set) 1
-posthog.Team warehouse_sources.WarehouseColumnStatistics.team reverse-accessor(warehousecolumnstatistics_set) 1
-posthog.Team web_analytics.SavedHeatmap.team reverse-accessor(savedheatmap_set) 1
-posthog.Team web_analytics.WebAnalyticsAchievementProgress.team reverse-accessor(webanalyticsachievementprogress_set) 1
-posthog.Team web_analytics.WebAnalyticsFilterPreset.team reverse-accessor(webanalyticsfilterpreset_set) 1
-posthog.Team web_analytics.WebAnalyticsInteraction.team reverse-accessor(webanalyticsinteraction_set) 1
-posthog.Team web_analytics.WebAnalyticsUserConfig.team reverse-accessor(webanalyticsuserconfig_set) 1
-posthog.Team web_analytics.WebAnalyticsVisit.team reverse-accessor(webanalyticsvisit_set) 1
posthog.Team workflows.HogFlow.team reverse-accessor(hogflow_set) 1
posthog.Team workflows.HogFlowBatchJob.team reverse-accessor(hogflowbatchjob_set) 1
posthog.Team workflows.HogFlowRevision.team reverse-accessor(hogflowrevision_set) 1
@@ -415,27 +197,16 @@ posthog.Team workflows.HogFlowTemplate.team reverse-accessor(hogflowtemplate_set
posthog.Team workflows.TeamWorkflowsConfig.team reverse-accessor(teamworkflowsconfig) 1
posthog.User access_control.AccessControl.created_by reverse-accessor(accesscontrol_set) 1
posthog.User access_control.OrganizationResourceAccess.created_by reverse-accessor(organizationresourceaccess_set) 1
-posthog.User access_control.PropertyAccessControl.created_by reverse-accessor(propertyaccesscontrol_set) 1
posthog.User access_control.Role.created_by reverse-accessor(roles) 1
posthog.User access_control.Role.members reverse-accessor(role_set) 1
posthog.User access_control.RoleExternalReference.created_by reverse-accessor(roleexternalreference_set) 1
posthog.User access_control.RoleMembership.user reverse-accessor(role_memberships) 1
posthog.User actions.Action.created_by reverse-accessor(action_set) 1
-posthog.User ai_observability.Dataset.created_by reverse-accessor(dataset_set) 1
-posthog.User ai_observability.DatasetItem.created_by reverse-accessor(datasetitem_set) 1
-posthog.User ai_observability.DatasetItemVersion.created_by reverse-accessor(datasetitemversion_set) 1
-posthog.User ai_observability.DatasetRevision.created_by reverse-accessor(datasetrevision_set) 1
-posthog.User ai_observability.Evaluation.created_by reverse-accessor(evaluation_set) 1
-posthog.User ai_observability.EvaluationReport.created_by reverse-accessor(evaluationreport_set) 1
-posthog.User ai_observability.LLMPrompt.created_by reverse-accessor(llmprompt_set) 1
-posthog.User ai_observability.LLMPromptLabel.created_by reverse-accessor(llmpromptlabel_set) 1
-posthog.User ai_observability.LLMProviderKey.created_by reverse-accessor(llmproviderkey_set) 1
posthog.User ai_observability.ParserRecipe.created_by reverse-accessor(parserrecipe_set) 1
posthog.User ai_observability.ReviewQueue.created_by reverse-accessor(reviewqueue_set) 1
posthog.User ai_observability.ReviewQueueItem.created_by reverse-accessor(reviewqueueitem_set) 1
posthog.User ai_observability.ScoreDefinition.created_by reverse-accessor(scoredefinition_set) 1
posthog.User ai_observability.ScoreDefinitionVersion.created_by reverse-accessor(scoredefinitionversion_set) 1
-posthog.User ai_observability.Tagger.created_by reverse-accessor(tagger_set) 1
posthog.User ai_observability.TraceReview.created_by reverse-accessor(tracereview_set) 1
posthog.User ai_observability.TraceReviewScore.created_by reverse-accessor(tracereviewscore_set) 1
posthog.User alerts.AlertConfiguration.created_by reverse-accessor(alertconfiguration_set) 1
@@ -444,94 +215,52 @@ posthog.User alerts.AlertSubscription.created_by reverse-accessor(alertsubscript
posthog.User alerts.AlertSubscription.user reverse-accessor(alert_subscriptions) 1
posthog.User alerts.Threshold.created_by reverse-accessor(threshold_set) 1
posthog.User analytics_platform.PreaggregationJob.created_by reverse-accessor(preaggregationjob_set) 1
-posthog.User annotations.Annotation.created_by reverse-accessor(annotation_set) 1
posthog.User approvals.Approval.created_by reverse-accessor(approval_set) 1
posthog.User approvals.ApprovalPolicy.created_by reverse-accessor(approvalpolicy_set) 1
posthog.User approvals.ChangeRequest.applied_by reverse-accessor(change_requests_applied) 1
posthog.User approvals.ChangeRequest.created_by reverse-accessor(changerequest_set) 1
posthog.User business_knowledge.KnowledgeSource.created_by reverse-accessor(knowledgesource_set) 1
-posthog.User canvas.Canvas.created_by reverse-accessor(canvas_set) 1
-posthog.User canvas.CanvasHomePreference.user reverse-accessor(canvashomepreference_set) 1
-posthog.User canvas.CanvasSourceVersion.created_by reverse-accessor(canvassourceversion_set) 1
-posthog.User canvas.CanvasState.user reverse-accessor(canvasstate_set) 1
posthog.User cdp.HogFunction.created_by reverse-accessor(hogfunction_set) 1
posthog.User cdp.HogFunctionRevision.created_by reverse-accessor(hogfunctionrevision_set) 1
posthog.User cdp.Hook.user reverse-accessor(rest_hooks) 1
-posthog.User cohorts.Cohort.created_by reverse-accessor(cohort_set) 1
posthog.User conversations.EmailChannel.owner reverse-accessor(owned_conversations_email_channels) 1
-posthog.User conversations.TicketAssignment.user reverse-accessor(ticketassignment_set) 1
posthog.User conversations.TicketView.created_by reverse-accessor(ticketview_set) 1
-posthog.User conversations.TicketViewFavorite.user reverse-accessor(ticketviewfavorite_set) 1
posthog.User customer_analytics.Account.created_by reverse-accessor(account_set) 1
-posthog.User customer_analytics.AccountRelationship.created_by reverse-accessor(accountrelationship_set) 1
-posthog.User customer_analytics.AccountRelationshipDefinition.created_by reverse-accessor(accountrelationshipdefinition_set) 1
-posthog.User customer_analytics.AccountTrackRuleRun.created_by reverse-accessor(accounttrackrulerun_set) 1
-posthog.User customer_analytics.Announcement.created_by reverse-accessor(announcement_set) 1
posthog.User customer_analytics.CustomPropertyDefinition.created_by reverse-accessor(custompropertydefinition_set) 1
-posthog.User customer_analytics.CustomPropertySource.created_by reverse-accessor(custompropertysource_set) 1
-posthog.User customer_analytics.CustomPropertySyncRun.created_by reverse-accessor(custompropertysyncrun_set) 1
-posthog.User customer_analytics.CustomPropertyValue.created_by reverse-accessor(custompropertyvalue_set) 1
posthog.User customer_analytics.CustomerJourney.created_by reverse-accessor(customerjourney_set) 1
posthog.User customer_analytics.CustomerProfileConfig.created_by reverse-accessor(customerprofileconfig_set) 1
-posthog.User customer_analytics.EventStream.created_by reverse-accessor(eventstream_set) 1
-posthog.User customer_analytics.EventStreamMember.created_by reverse-accessor(eventstreammember_set) 1
-posthog.User dashboards.ButtonTile.created_by reverse-accessor(buttontile_set) 1
posthog.User dashboards.ButtonTile.last_modified_by reverse-accessor(modified_button_tiles) 1
-posthog.User dashboards.Dashboard.created_by reverse-accessor(dashboard_set) 1
-posthog.User dashboards.DashboardTemplate.created_by reverse-accessor(dashboardtemplate_set) 1
-posthog.User dashboards.DashboardWidget.created_by reverse-accessor(dashboardwidget_set) 1
posthog.User dashboards.DashboardWidget.last_modified_by reverse-accessor(modified_dashboard_widgets) 1
posthog.User dashboards.Text.created_by reverse-accessor(text_set) 1
posthog.User dashboards.Text.last_modified_by reverse-accessor(modified_text_tiles) 1
-posthog.User data_catalog.RelationshipProposal.created_by reverse-accessor(relationshipproposal_set) 1
-posthog.User data_catalog.TableCertification.created_by reverse-accessor(tablecertification_set) 1
posthog.User data_modeling.DAG.created_by reverse-accessor(dag_set) 1
posthog.User data_modeling.DataModelingJob.created_by reverse-accessor(datamodelingjob_set) 1
posthog.User data_modeling.DataWarehouseManagedViewSet.created_by reverse-accessor(datawarehousemanagedviewset_set) 1
posthog.User data_modeling.DataWarehouseModelPath.created_by reverse-accessor(datawarehousemodelpath_set) 1
posthog.User data_modeling.DataWarehouseSavedQuery.created_by reverse-accessor(datawarehousesavedquery_set) 1
-posthog.User data_modeling.DataWarehouseSavedQueryColumnAnnotation.created_by reverse-accessor(datawarehousesavedquerycolumnannotation_set) 1
posthog.User data_modeling.DataWarehouseSavedQueryDraft.created_by reverse-accessor(datawarehousesavedquerydraft_set) 1
posthog.User data_modeling.Edge.created_by reverse-accessor(edge_set) 1
posthog.User data_modeling.GitHubSyncConfig.created_by reverse-accessor(githubsyncconfig_set) 1
posthog.User data_modeling.GitHubSyncPlan.created_by reverse-accessor(githubsyncplan_set) 1
posthog.User data_modeling.GitHubSyncedModel.created_by reverse-accessor(githubsyncedmodel_set) 1
posthog.User data_modeling.Node.created_by reverse-accessor(node_set) 1
-posthog.User data_tools.DataWarehouseExpression.created_by reverse-accessor(datawarehouseexpression_set) 1
posthog.User data_tools.DataWarehouseJoin.created_by reverse-accessor(datawarehousejoin_set) 1
posthog.User data_tools.DataWarehouseSavedQueryFolder.created_by reverse-accessor(datawarehousesavedqueryfolder_set) 1
posthog.User data_tools.DataWarehouseViewLink.created_by reverse-accessor(datawarehouseviewlink_set) 1
posthog.User data_tools.QueryTabState.created_by reverse-accessor(querytabstate_set) 1
posthog.User early_access_features.EarlyAccessFeature.created_by reverse-accessor(early_access_features) 1
-posthog.User endpoints.Endpoint.created_by reverse-accessor(endpoint_set) 1
posthog.User endpoints.EndpointVersion.created_by reverse-accessor(endpoint_versions_created) 1
-posthog.User error_tracking.ErrorTrackingAssignmentRule.user reverse-accessor(errortrackingassignmentrule_set) 1
-posthog.User error_tracking.ErrorTrackingGroup.assignee reverse-accessor(errortrackinggroup_set) 1
-posthog.User error_tracking.ErrorTrackingGroupingRule.user reverse-accessor(errortrackinggroupingrule_set) 1
-posthog.User error_tracking.ErrorTrackingIssueAssignment.user reverse-accessor(errortrackingissueassignment_set) 1
posthog.User event_definitions.SchemaPropertyGroup.created_by reverse-accessor(created_schema_property_groups) 1
posthog.User experiments.Experiment.created_by reverse-accessor(experiment_set) 1
-posthog.User experiments.ExperimentHoldout.created_by reverse-accessor(experimentholdout_set) 1
-posthog.User experiments.ExperimentMetricsRecalculation.created_by reverse-accessor(experimentmetricsrecalculation_set) 1
-posthog.User experiments.ExperimentSavedMetric.created_by reverse-accessor(experimentsavedmetric_set) 1
posthog.User exports.ExportedAsset.created_by reverse-accessor(exportedasset_set) 1
-posthog.User exports.Subscription.created_by reverse-accessor(subscription_set) 1
-posthog.User feature_flags.FeatureFlag.created_by reverse-accessor(featureflag_set) 1
posthog.User feature_flags.FeatureFlag.last_modified_by reverse-accessor(updated_feature_flags) 1
-posthog.User feature_flags.FeatureFlagOverride.user reverse-accessor(featureflagoverride_set) 1
-posthog.User feature_flags.ScheduledChange.created_by reverse-accessor(scheduledchange_set) 1
posthog.User field_notes.FieldNote.created_by reverse-accessor(fieldnote_set) 1
-posthog.User growth.EnrichmentPromptConfig.created_by reverse-accessor(enrichmentpromptconfig_set) 1
-posthog.User growth.IcpScoringConfig.created_by reverse-accessor(icpscoringconfig_set) 1
-posthog.User growth.ProductPushCampaign.created_by reverse-accessor(productpushcampaign_set) 1
posthog.User legal_documents.LegalDocument.created_by reverse-accessor(legaldocument_set) 1
posthog.User links.Link.created_by reverse-accessor(link_set) 1
posthog.User logs.LogsAlertConfiguration.created_by reverse-accessor(logsalertconfiguration_set) 1
posthog.User logs.LogsExclusionRule.created_by reverse-accessor(logsexclusionrule_set) 1
-posthog.User logs.LogsRetentionRule.created_by reverse-accessor(logsretentionrule_set) 1
posthog.User logs.LogsView.created_by reverse-accessor(logsview_set) 1
posthog.User managed_warehouse.DuckgresServer.created_by reverse-accessor(duckgresserver_set) 1
-posthog.User managed_warehouse.ManagedWarehouseSourceJob.created_by reverse-accessor(managedwarehousesourcejob_set) 1
posthog.User mcp_store.MCPOAuthState.created_by reverse-accessor(mcpoauthstate_set) 1
posthog.User mcp_store.MCPServerInstallation.created_by reverse-accessor(mcpserverinstallation_set) 1
posthog.User mcp_store.MCPServerInstallation.user reverse-accessor(mcp_server_installations) 1
@@ -541,15 +270,11 @@ posthog.User messaging.MessageCategory.created_by reverse-accessor(messagecatego
posthog.User messaging.MessageRecipientPreference.created_by reverse-accessor(messagerecipientpreference_set) 1
posthog.User messaging.MessageSuppression.created_by reverse-accessor(messagesuppression_set) 1
posthog.User messaging.MessageTemplate.created_by reverse-accessor(messagetemplate_set) 1
-posthog.User notebooks.KernelRuntime.user reverse-accessor(kernelruntime_set) 1
-posthog.User notebooks.Notebook.created_by reverse-accessor(notebook_set) 1
posthog.User notebooks.Notebook.last_modified_by reverse-accessor(modified_notebooks) 1
-posthog.User notebooks.NotebookNodeRun.user reverse-accessor(notebooknoderun_set) 1
posthog.User notifications.NotificationArchiveState.user reverse-accessor(notification_archive_states) 1
posthog.User notifications.NotificationReadState.user reverse-accessor(notification_read_states) 1
posthog.User posthog_ai.AgentArtifact.created_by reverse-accessor(agentartifact_set) 1
posthog.User posthog_ai.AgentMemory.user reverse-accessor(agent_memories) 1
-posthog.User posthog_ai.Conversation.user reverse-accessor(conversation_set) 1
posthog.User product_analytics.Insight.created_by reverse-accessor(insight_set) 1
posthog.User product_analytics.Insight.last_modified_by reverse-accessor(modified_insights) 1
posthog.User product_analytics.InsightVariable.created_by reverse-accessor(insightvariable_set) 1
@@ -561,47 +286,25 @@ posthog.User pulse.ProductBrief.created_by reverse-accessor(productbrief_set) 1
posthog.User pulse.ResourceLink.created_by reverse-accessor(resourcelink_set) 1
posthog.User reminders.Reminder.created_by reverse-accessor(reminder_set) 1
posthog.User replay.ExportedRecording.created_by reverse-accessor(exported_recordings) 1
-posthog.User signals.SignalSourceConfig.created_by reverse-accessor(signalsourceconfig_set) 1
posthog.User signals.SignalUserAutonomyConfig.user reverse-accessor(signal_autonomy_config) 1
-posthog.User skills.CommunitySkillVote.user reverse-accessor(communityskillvote_set) 1
-posthog.User skills.LLMSkill.created_by reverse-accessor(llmskill_set) 1
posthog.User slack_app.SlackChannel.approved_by reverse-accessor(approved_slack_channels) 1
-posthog.User streamlit_apps.StreamlitApp.created_by reverse-accessor(streamlitapp_set) 1
-posthog.User streamlit_apps.StreamlitAppVersion.created_by reverse-accessor(streamlitappversion_set) 1
posthog.User surveys.Survey.created_by reverse-accessor(surveys) 1
-posthog.User tasks.SandboxEnvironment.created_by reverse-accessor(sandboxenvironment_set) 1
-posthog.User tasks.Task.created_by reverse-accessor(task_set) 1
-posthog.User tracing.TracingView.created_by reverse-accessor(tracingview_set) 1
posthog.User user_interviews.IntervieweeContext.created_by reverse-accessor(intervieweecontext_set) 1
posthog.User user_interviews.UserInterview.created_by reverse-accessor(userinterview_set) 1
posthog.User user_interviews.UserInterviewTopic.created_by reverse-accessor(userinterviewtopic_set) 1
-posthog.User warehouse_sources.CustomOAuth2Integration.created_by reverse-accessor(customoauth2integration_set) 1
posthog.User warehouse_sources.DataWarehouseCredential.created_by reverse-accessor(datawarehousecredential_set) 1
posthog.User warehouse_sources.DataWarehouseTable.created_by reverse-accessor(datawarehousetable_set) 1
-posthog.User warehouse_sources.ExternalDataDestination.created_by reverse-accessor(externaldatadestination_set) 1
posthog.User warehouse_sources.ExternalDataJob.created_by reverse-accessor(externaldatajob_set) 1
posthog.User warehouse_sources.ExternalDataSchema.created_by reverse-accessor(externaldataschema_set) 1
posthog.User warehouse_sources.ExternalDataSource.created_by reverse-accessor(externaldatasource_set) 1
posthog.User warehouse_sources.PendingSourceCredential.created_by reverse-accessor(pendingsourcecredential_set) 1
posthog.User warehouse_sources.WarehouseColumnAnnotation.created_by reverse-accessor(warehousecolumnannotation_set) 1
-posthog.User warehouse_sources.WarehouseColumnStatistics.created_by reverse-accessor(warehousecolumnstatistics_set) 1
-posthog.User web_analytics.SavedHeatmap.created_by reverse-accessor(savedheatmap_set) 1
-posthog.User web_analytics.WebAnalyticsAchievementProgress.user reverse-accessor(webanalyticsachievementprogress_set) 1
-posthog.User web_analytics.WebAnalyticsFilterPreset.created_by reverse-accessor(webanalyticsfilterpreset_set) 1
posthog.User web_analytics.WebAnalyticsFilterPreset.last_modified_by reverse-accessor(modified_web_analytics_filter_presets) 1
-posthog.User web_analytics.WebAnalyticsInteraction.user reverse-accessor(webanalyticsinteraction_set) 1
-posthog.User web_analytics.WebAnalyticsUserConfig.user reverse-accessor(webanalyticsuserconfig_set) 1
-posthog.User web_analytics.WebAnalyticsVisit.user reverse-accessor(webanalyticsvisit_set) 1
posthog.User workflows.HogFlow.created_by reverse-accessor(hogflow_set) 1
posthog.User workflows.HogFlowBatchJob.created_by reverse-accessor(hogflowbatchjob_set) 1
posthog.User workflows.HogFlowRevision.created_by reverse-accessor(hogflowrevision_set) 1
posthog.User workflows.HogFlowTemplate.created_by reverse-accessor(hogflowtemplate_set) 1
-posthog.UserIntegration tasks.Task.github_user_integration reverse-accessor(task_set) 1
-product_analytics.Insight alerts.Alert.insight reverse-accessor(alert_set) 1
product_analytics.Insight alerts.AlertConfiguration.insight reverse-accessor(alertconfiguration_set) 1
-product_analytics.Insight alerts.Threshold.insight reverse-accessor(threshold_set) 1
-product_analytics.Insight annotations.Annotation.dashboard_item reverse-accessor(annotation_set) 1
-product_analytics.Insight customer_analytics.CustomerJourney.insight reverse-accessor(customerjourney_set) 1
product_analytics.Insight dashboards.Dashboard.insights reverse-accessor(dashboards) 1
product_analytics.Insight dashboards.DashboardTile.insight reverse-accessor(dashboard_tiles) 1
product_analytics.Insight ee.api.subscription instance-many(filter) 2
@@ -615,7 +318,6 @@ product_analytics.Insight ee.hogai.eval.ci.max_tools.eval_upsert_dashboard write
product_analytics.Insight ee.hogai.tools.upsert_dashboard.tool construct 1
product_analytics.Insight exports.ExportedAsset.insight reverse-accessor(exportedasset_set) 1
product_analytics.Insight exports.Subscription.dashboard_export_insights reverse-accessor(subscriptions_dashboard_export) 1
-product_analytics.Insight exports.Subscription.insight reverse-accessor(subscription_set) 1
product_analytics.Insight posthog.SharingConfiguration.insight reverse-accessor(sharingconfiguration_set) 1
product_analytics.Insight posthog.TaggedItem.insight reverse-accessor(tagged_items) 1
product_analytics.Insight posthog.api.cohort instance-many(order_by) 1
@@ -744,8 +446,6 @@ warehouse_sources.DataWarehouseCredential posthog.hogql.database.database instan
warehouse_sources.DataWarehouseCredential products.data_warehouse.backend.presentation.views.table drf-model-serializer 1
warehouse_sources.DataWarehouseCredential products.data_warehouse.backend.presentation.views.table write(create) 1
warehouse_sources.DataWarehouseCredential products.posthog_ai.evals.data_warehouse.seeder write(create) 1
-warehouse_sources.DataWarehouseTable data_modeling.DataWarehouseModelPath.table reverse-accessor(datawarehousemodelpath_set) 1
-warehouse_sources.DataWarehouseTable data_modeling.DataWarehouseSavedQuery.table reverse-accessor(datawarehousesavedquery_set) 1
warehouse_sources.DataWarehouseTable ee.hogai.eval.offline.snapshot_loader write(abulk_create) 1
warehouse_sources.DataWarehouseTable ee.hogai.eval.schema construct 1
warehouse_sources.DataWarehouseTable ee.hogai.eval.schema in-collection 1
diff --git a/products/notebooks/backend/migrations/0020_alter_kernelruntime_team_alter_kernelruntime_user_and_more.py b/products/notebooks/backend/migrations/0020_alter_kernelruntime_team_alter_kernelruntime_user_and_more.py
new file mode 100644
index 000000000000..2da78713c381
--- /dev/null
+++ b/products/notebooks/backend/migrations/0020_alter_kernelruntime_team_alter_kernelruntime_user_and_more.py
@@ -0,0 +1,79 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("notebooks", "0019_squash_2026_09_07_schema_addons"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="kernelruntime",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="kernelruntime",
+ name="user",
+ 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="notebook",
+ 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="notebook",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="notebooknoderun",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="notebooknoderun",
+ name="user",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.DO_NOTHING,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ]
diff --git a/products/notebooks/backend/migrations/max_migration.txt b/products/notebooks/backend/migrations/max_migration.txt
index 814d850ec43c..f90ecdac735f 100644
--- a/products/notebooks/backend/migrations/max_migration.txt
+++ b/products/notebooks/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0019_squash_2026_09_07_schema_addons
+0020_alter_kernelruntime_team_alter_kernelruntime_user_and_more
diff --git a/products/notebooks/backend/models.py b/products/notebooks/backend/models.py
index deb0e3314bdf..ae3ecff4ef29 100644
--- a/products/notebooks/backend/models.py
+++ b/products/notebooks/backend/models.py
@@ -25,7 +25,7 @@ class Notebook(FileSystemSyncMixin, RootTeamMixin, UUIDTModel):
DEFAULT = "default", "default"
short_id = models.CharField(max_length=12, blank=True, default=generate_short_id)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
title = models.CharField(max_length=256, blank=True, null=True)
content: JSONField = JSONField(default=None, null=True, blank=True)
text_content = models.TextField(blank=True, null=True)
@@ -33,7 +33,7 @@ class Notebook(FileSystemSyncMixin, RootTeamMixin, UUIDTModel):
visibility = models.CharField(choices=Visibility, default=Visibility.DEFAULT, max_length=20)
version = models.IntegerField(default=0)
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="+")
last_modified_at = models.DateTimeField(default=timezone.now)
last_modified_by = models.ForeignKey(
"posthog.User",
@@ -163,10 +163,10 @@ class KernelRuntime(UUIDTModel):
DISCARDED = "discarded", "discarded"
ERROR = "error", "error"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
notebook = models.ForeignKey("notebooks.Notebook", on_delete=models.SET_NULL, null=True, blank=True)
notebook_short_id = models.CharField(max_length=12)
- user = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True)
+ user = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True, related_name="+")
created_at = models.DateTimeField(auto_now_add=True)
last_used_at = models.DateTimeField(default=timezone.now)
status = models.CharField(choices=Status, default=Status.STARTING, max_length=20)
@@ -222,7 +222,7 @@ class NotebookNodeRun(TeamScopedRootMixin, UUIDModel):
# db_constraint=False: creating a real FK to the hot posthog_team table locks it on deploy.
# Tenant isolation is still enforced by the fail-closed TeamScopedRootMixin manager.
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
notebook = models.ForeignKey("notebooks.Notebook", on_delete=models.CASCADE)
# Who ran it. Kernels are per user, so this is the second half of a KernelRuntime's scope —
# the callback needs it to file the frame snapshot without a user-blind lookup by id.
@@ -233,7 +233,13 @@ class NotebookNodeRun(TeamScopedRootMixin, UUIDModel):
# table that grows fastest. Nothing enforces referential integrity here anyway
# (db_constraint=False), and a dangling id already reads back as None.
user = models.ForeignKey(
- "posthog.User", on_delete=models.DO_NOTHING, null=True, blank=True, db_constraint=False, db_index=False
+ "posthog.User",
+ on_delete=models.DO_NOTHING,
+ null=True,
+ blank=True,
+ db_constraint=False,
+ db_index=False,
+ related_name="+",
)
node_id = models.CharField(max_length=128)
# How the run executed: hogql pushed to ClickHouse (pages re-query by `code`); python and
diff --git a/products/notifications/backend/migrations/0026_alter_notificationevent_organization_and_more.py b/products/notifications/backend/migrations/0026_alter_notificationevent_organization_and_more.py
new file mode 100644
index 000000000000..5ac8d7f71258
--- /dev/null
+++ b/products/notifications/backend/migrations/0026_alter_notificationevent_organization_and_more.py
@@ -0,0 +1,34 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("notifications", "0025_callable_choices"),
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="notificationevent",
+ name="organization",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.organization",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="notificationevent",
+ name="team",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/notifications/backend/migrations/max_migration.txt b/products/notifications/backend/migrations/max_migration.txt
index 77f7766af773..64958b86ee4c 100644
--- a/products/notifications/backend/migrations/max_migration.txt
+++ b/products/notifications/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0025_callable_choices
+0026_alter_notificationevent_organization_and_more
diff --git a/products/notifications/backend/models.py b/products/notifications/backend/models.py
index 0d47b5c7d334..3703a352c275 100644
--- a/products/notifications/backend/models.py
+++ b/products/notifications/backend/models.py
@@ -16,8 +16,8 @@ def priority_choices() -> list[tuple[str, str | Promise]]:
class NotificationEvent(UUIDModel):
- organization = models.ForeignKey("posthog.Organization", on_delete=models.CASCADE)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, null=True, blank=True)
+ organization = models.ForeignKey("posthog.Organization", on_delete=models.CASCADE, related_name="+")
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, null=True, blank=True, related_name="+")
notification_type = models.CharField(max_length=32, choices=notification_type_choices)
priority = models.CharField(max_length=16, choices=priority_choices, default=Priority.NORMAL)
title = models.CharField(max_length=255)
diff --git a/products/posthog_ai/backend/migrations/0002_alter_agentartifact_team_alter_conversation_team_and_more.py b/products/posthog_ai/backend/migrations/0002_alter_agentartifact_team_alter_conversation_team_and_more.py
new file mode 100644
index 000000000000..4b511a903fa6
--- /dev/null
+++ b/products/posthog_ai/backend/migrations/0002_alter_agentartifact_team_alter_conversation_team_and_more.py
@@ -0,0 +1,43 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ("posthog_ai", "0001_squash_2026_09_07_initial"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="agentartifact",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="conversation",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="conversation",
+ name="user",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ]
diff --git a/products/posthog_ai/backend/migrations/max_migration.txt b/products/posthog_ai/backend/migrations/max_migration.txt
index 6903cd5e3dc2..3cc14001606b 100644
--- a/products/posthog_ai/backend/migrations/max_migration.txt
+++ b/products/posthog_ai/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_squash_2026_09_07_initial
+0002_alter_agentartifact_team_alter_conversation_team_and_more
diff --git a/products/posthog_ai/backend/models/assistant.py b/products/posthog_ai/backend/models/assistant.py
index e15f3c1d5aa7..4f11df4ccd55 100644
--- a/products/posthog_ai/backend/models/assistant.py
+++ b/products/posthog_ai/backend/models/assistant.py
@@ -67,8 +67,8 @@ class Conversation(UUIDTModel, DeletedMetaFields):
DATA_WAREHOUSE = "data_warehouse", "Data warehouse"
OTHER = "other", "Other"
- user = models.ForeignKey(User, on_delete=models.CASCADE)
- team = models.ForeignKey(Team, on_delete=models.CASCADE)
+ user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="+")
+ team = models.ForeignKey(Team, on_delete=models.CASCADE, related_name="+")
created_at = models.DateTimeField(auto_now_add=True, null=True)
updated_at = models.DateTimeField(auto_now=True, null=True)
status = models.CharField(max_length=20, choices=Status, default=Status.IDLE)
@@ -338,7 +338,7 @@ class AgentArtifact(UUIDModel, CreatedMetaFields, UpdatedMetaFields, DeletedMeta
type = models.CharField(max_length=50, choices=Type)
data = models.JSONField(help_text="Artifact content. Structure depends on artifact type.")
conversation = models.ForeignKey(Conversation, on_delete=models.CASCADE, related_name="artifacts")
- team = models.ForeignKey(Team, on_delete=models.CASCADE)
+ team = models.ForeignKey(Team, on_delete=models.CASCADE, related_name="+")
class Meta:
indexes = [
diff --git a/products/product_analytics/backend/migrations/0009_alter_insightvariable_team.py b/products/product_analytics/backend/migrations/0009_alter_insightvariable_team.py
new file mode 100644
index 000000000000..6a9c50d61e80
--- /dev/null
+++ b/products/product_analytics/backend/migrations/0009_alter_insightvariable_team.py
@@ -0,0 +1,23 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ("product_analytics", "0008_repair_insightviewed_null_unique_index"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="insightvariable",
+ 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.txt
index a05acdc6dd8b..d09ebcaed57c 100644
--- a/products/product_analytics/backend/migrations/max_migration.txt
+++ b/products/product_analytics/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0008_repair_insightviewed_null_unique_index
+0009_alter_insightvariable_team
diff --git a/products/product_analytics/backend/models/insight_variable.py b/products/product_analytics/backend/models/insight_variable.py
index 847437d8c731..6003bdf2b127 100644
--- a/products/product_analytics/backend/models/insight_variable.py
+++ b/products/product_analytics/backend/models/insight_variable.py
@@ -8,7 +8,7 @@ from products.product_analytics.backend.facade import enums
class InsightVariable(UUIDTModel, RootTeamMixin, CreatedMetaFields, UpdatedMetaFields):
Type = enums.InsightVariableType
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
name = models.CharField(max_length=400)
code_name = models.CharField(max_length=400, null=True, blank=True)
type = models.CharField(max_length=128, choices=Type)
diff --git a/products/reminders/backend/migrations/0002_alter_reminder_organization_alter_reminder_team.py b/products/reminders/backend/migrations/0002_alter_reminder_organization_alter_reminder_team.py
new file mode 100644
index 000000000000..691b50932434
--- /dev/null
+++ b/products/reminders/backend/migrations/0002_alter_reminder_organization_alter_reminder_team.py
@@ -0,0 +1,34 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ("reminders", "0001_squash_2026_09_07_initial"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="reminder",
+ name="organization",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.organization",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="reminder",
+ name="team",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/reminders/backend/migrations/max_migration.txt b/products/reminders/backend/migrations/max_migration.txt
index 6903cd5e3dc2..c43ee9308b8e 100644
--- a/products/reminders/backend/migrations/max_migration.txt
+++ b/products/reminders/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0001_squash_2026_09_07_initial
+0002_alter_reminder_organization_alter_reminder_team
diff --git a/products/reminders/backend/models/reminder.py b/products/reminders/backend/models/reminder.py
index 277bc75d896c..0e043430644f 100644
--- a/products/reminders/backend/models/reminder.py
+++ b/products/reminders/backend/models/reminder.py
@@ -16,8 +16,8 @@ class Reminder(RootTeamMixin, CreatedMetaFields, UpdatedMetaFields, UUIDModel):
MONTHLY = "monthly", "Monthly"
YEARLY = "yearly", "Yearly"
- organization = models.ForeignKey("posthog.Organization", on_delete=models.CASCADE)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, null=True, blank=True)
+ organization = models.ForeignKey("posthog.Organization", on_delete=models.CASCADE, related_name="+")
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, null=True, blank=True, related_name="+")
title = models.CharField(max_length=255)
message = models.TextField(blank=True, default="")
diff --git a/products/signals/backend/migrations/0122_alter_signalemissionrecord_team_and_more.py b/products/signals/backend/migrations/0122_alter_signalemissionrecord_team_and_more.py
new file mode 100644
index 000000000000..07fdcb19123e
--- /dev/null
+++ b/products/signals/backend/migrations/0122_alter_signalemissionrecord_team_and_more.py
@@ -0,0 +1,83 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ("signals", "0121_signalscoutconfig_display_name"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="signalemissionrecord",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="signalreport",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="signalreportaction",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="signalreportartefact",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="signalreportrefund",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="signalreporttask",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="signalsourceconfig",
+ 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,
+ ),
+ ),
+ ]
diff --git a/products/signals/backend/migrations/max_migration.txt b/products/signals/backend/migrations/max_migration.txt
index 07ed4d829810..80206808045e 100644
--- a/products/signals/backend/migrations/max_migration.txt
+++ b/products/signals/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0121_signalscoutconfig_display_name
+0122_alter_signalemissionrecord_team_and_more
diff --git a/products/signals/backend/models.py b/products/signals/backend/models.py
index 7088231b3111..05b9fde62454 100644
--- a/products/signals/backend/models.py
+++ b/products/signals/backend/models.py
@@ -97,7 +97,7 @@ class SignalSourceConfig(UUIDModel):
config = models.JSONField(default=dict)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=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="+")
@classmethod
def is_source_enabled(cls, team_id: int, source_product: str, source_type: str) -> bool:
@@ -249,7 +249,7 @@ class SignalReport(UUIDModel):
POSTHOG_ONBOARDING = "posthog_onboarding", "PostHog onboarding"
POSTHOG_SYSTEM = "posthog_system", "PostHog system"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
status = models.CharField(max_length=20, choices=Status, default=Status.POTENTIAL)
# System billing exemption: non-null means this report's implementation PRs must never be
# charged (PostHog-system origins, e.g. health-check scout findings). Prospective-only —
@@ -874,7 +874,7 @@ class SignalEmissionRecord(UUIDModel):
One row per source record, upserted on emission.
"""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
source_product = models.CharField(max_length=100)
source_type = models.CharField(max_length=100)
source_id = models.CharField(max_length=200)
@@ -954,7 +954,7 @@ class SignalReportArtefact(UUIDModel):
}
)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
report = models.ForeignKey(SignalReport, on_delete=models.CASCADE, related_name="artefacts")
type = models.CharField(max_length=100, choices=signal_report_artefact_type_choices)
content = models.TextField()
@@ -1209,7 +1209,7 @@ class SignalReportTask(UUIDModel):
solely for the implementation gate during that transition.
"""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
report = models.ForeignKey(SignalReport, on_delete=models.CASCADE, related_name="report_tasks")
task = models.ForeignKey("tasks.Task", on_delete=models.CASCADE, related_name="signal_report_tasks")
# "implementation" for the rows the gate reads; legacy rows also carry "research" /
@@ -1265,7 +1265,7 @@ class SignalReportRefund(TeamScopedRootMixin, UUIDModel):
# FKs to the hot posthog_team / posthog_user tables use db_constraint=False so creating this
# table takes no lock on those parents (app-level enforcement only).
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
# RESTRICT: hard-deleting a report must never silently destroy this financial record (it drives
# the quota offset and refund audit). Team deletion still cascades in via the team FK above.
report = models.OneToOneField(SignalReport, on_delete=models.RESTRICT, related_name="refund")
@@ -1332,7 +1332,7 @@ class SignalReportAction(TeamScopedRootMixin, UUIDModel):
# FKs to the hot posthog_team / posthog_user tables use db_constraint=False so creating this
# table takes no lock on those parents (app-level enforcement only).
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
report = models.ForeignKey(SignalReport, on_delete=models.CASCADE, related_name="actions")
# CASCADE, unlike the artefact log's SET_NULL: a row here is evidence that a specific person
# interacted, so with the person gone it proves nothing and can go with them.
diff --git a/products/skills/backend/migrations/0008_alter_communityskillvote_user_and_more.py b/products/skills/backend/migrations/0008_alter_communityskillvote_user_and_more.py
new file mode 100644
index 000000000000..85c653645e18
--- /dev/null
+++ b/products/skills/backend/migrations/0008_alter_communityskillvote_user_and_more.py
@@ -0,0 +1,46 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ("skills", "0007_llmskill_team_name_version_idx"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="communityskillvote",
+ name="user",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="llmskill",
+ 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="llmskill",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/skills/backend/migrations/max_migration.txt b/products/skills/backend/migrations/max_migration.txt
index db774a9c187f..9e91a633a690 100644
--- a/products/skills/backend/migrations/max_migration.txt
+++ b/products/skills/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0007_llmskill_team_name_version_idx
+0008_alter_communityskillvote_user_and_more
diff --git a/products/skills/backend/models/community_skills.py b/products/skills/backend/models/community_skills.py
index 1a857ae18edc..de6373778338 100644
--- a/products/skills/backend/models/community_skills.py
+++ b/products/skills/backend/models/community_skills.py
@@ -87,5 +87,5 @@ class CommunitySkillVote(UUIDModel):
skill = models.ForeignKey(CommunitySkill, on_delete=models.CASCADE, related_name="votes")
# db_constraint=False: posthog_user is a hot table — a real FK constraint takes a SHARE ROW
# EXCLUSIVE lock on it at create time. Cascade is still enforced by the ORM collector.
- user = models.ForeignKey("posthog.User", on_delete=models.CASCADE, db_constraint=False)
+ user = models.ForeignKey("posthog.User", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_at = models.DateTimeField(default=timezone.now)
diff --git a/products/skills/backend/models/skills.py b/products/skills/backend/models/skills.py
index ecf1fffe1d95..2d7cc3e4d8af 100644
--- a/products/skills/backend/models/skills.py
+++ b/products/skills/backend/models/skills.py
@@ -67,13 +67,8 @@ class LLMSkill(UUIDModel):
is_latest = models.BooleanField(default=True)
version_description = models.CharField(max_length=400, null=True, blank=True)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
- created_by = models.ForeignKey(
- "posthog.User",
- on_delete=models.SET_NULL,
- null=True,
- blank=True,
- )
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
+ created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True, related_name="+")
created_at = models.DateTimeField(default=timezone.now)
updated_at = models.DateTimeField(auto_now=True)
diff --git a/products/streamlit_apps/backend/migrations/0005_alter_streamlitapp_created_by_and_more.py b/products/streamlit_apps/backend/migrations/0005_alter_streamlitapp_created_by_and_more.py
new file mode 100644
index 000000000000..e2190fc0698e
--- /dev/null
+++ b/products/streamlit_apps/backend/migrations/0005_alter_streamlitapp_created_by_and_more.py
@@ -0,0 +1,47 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ("streamlit_apps", "0004_squash_2026_09_07_finalize_fks"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="streamlitapp",
+ 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="streamlitapp",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="streamlitappversion",
+ 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,
+ ),
+ ),
+ ]
diff --git a/products/streamlit_apps/backend/migrations/max_migration.txt b/products/streamlit_apps/backend/migrations/max_migration.txt
index bde7efb4f341..5c3fe041fb8f 100644
--- a/products/streamlit_apps/backend/migrations/max_migration.txt
+++ b/products/streamlit_apps/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0004_squash_2026_09_07_finalize_fks
+0005_alter_streamlitapp_created_by_and_more
diff --git a/products/streamlit_apps/backend/models.py b/products/streamlit_apps/backend/models.py
index 70445bdb85de..b554aaa5b2b9 100644
--- a/products/streamlit_apps/backend/models.py
+++ b/products/streamlit_apps/backend/models.py
@@ -22,7 +22,7 @@ class StreamlitApp(TeamScopedRootMixin):
# nosemgrep: prefer-uuid7-django-pk -- TODO: migrate to uuid7 or clarify intent
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
short_id = models.CharField(max_length=12, blank=True, default=generate_short_id)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
name = models.CharField(max_length=255)
description = models.TextField(blank=True, default="")
@@ -43,7 +43,7 @@ class StreamlitApp(TeamScopedRootMixin):
deleted = models.BooleanField(default=False)
deleted_at = models.DateTimeField(null=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="+")
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
@@ -73,7 +73,7 @@ class StreamlitAppVersion(models.Model):
snapshot_id = models.CharField(max_length=255, null=True, blank=True)
snapshot_created_at = models.DateTimeField(null=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="+")
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
diff --git a/products/surveys/backend/models.py b/products/surveys/backend/models.py
index 26305884bdf6..17cb8ec52458 100644
--- a/products/surveys/backend/models.py
+++ b/products/surveys/backend/models.py
@@ -299,6 +299,9 @@ class Survey(FileSystemSyncMixin, RootTeamMixin, UUIDTModel):
),
)
+ # Not sealed: the resource transfer graph walks reverse descriptors, so hiding
+ # survey_set would silently drop the survey link from Action-rooted duplications
+ # (test_relation_fields_Action locks the field list).
actions = models.ManyToManyField(Action)
@classmethod
diff --git a/products/tasks/backend/migrations/0122_alter_desktopbetatermsacceptance_organization_and_more.py b/products/tasks/backend/migrations/0122_alter_desktopbetatermsacceptance_organization_and_more.py
new file mode 100644
index 000000000000..0db2c750a51a
--- /dev/null
+++ b/products/tasks/backend/migrations/0122_alter_desktopbetatermsacceptance_organization_and_more.py
@@ -0,0 +1,116 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ("tasks", "0121_squash_2026_09_07_finalize_fks"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="desktopbetatermsacceptance",
+ name="organization",
+ field=models.OneToOneField(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ related_name="+",
+ serialize=False,
+ to="posthog.organization",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="sandboxenvironment",
+ 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="sandboxenvironment",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="task",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_index=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="task",
+ name="github_integration",
+ field=models.ForeignKey(
+ blank=True,
+ help_text="GitHub integration for this task",
+ limit_choices_to={"kind": "github"},
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="posthog.integration",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="task",
+ name="github_user_integration",
+ field=models.ForeignKey(
+ blank=True,
+ db_index=False,
+ help_text="User-scoped GitHub integration used for user-authored task runs",
+ limit_choices_to={"kind": "github"},
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="posthog.userintegration",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="task",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="taskrun",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="taskworkflowdispatch",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ db_index=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/tasks/backend/migrations/max_migration.txt b/products/tasks/backend/migrations/max_migration.txt
index 3a56801bfe11..7c77f62deb5c 100644
--- a/products/tasks/backend/migrations/max_migration.txt
+++ b/products/tasks/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0121_squash_2026_09_07_finalize_fks
+0122_alter_desktopbetatermsacceptance_organization_and_more
diff --git a/products/tasks/backend/models.py b/products/tasks/backend/models.py
index 637075098acd..5abe1572103b 100644
--- a/products/tasks/backend/models.py
+++ b/products/tasks/backend/models.py
@@ -379,8 +379,10 @@ class Task(DeletedMetaFields, models.Model):
# nosemgrep: prefer-uuid7-django-pk -- TODO: migrate to uuid7 or clarify intent
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
- created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_index=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
+ created_by = models.ForeignKey(
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_index=False, related_name="+"
+ )
task_number = models.IntegerField(null=True, blank=True)
title = models.CharField(max_length=255)
title_manually_set = models.BooleanField(default=False)
@@ -402,6 +404,7 @@ class Task(DeletedMetaFields, models.Model):
blank=True,
limit_choices_to={"kind": "github"},
help_text="GitHub integration for this task",
+ related_name="+",
)
# Keep the selected personal installation as a preference for deterministic
# authorship when a user has multiple GitHub installations. SET_NULL on
@@ -414,6 +417,7 @@ class Task(DeletedMetaFields, models.Model):
db_index=False,
limit_choices_to={"kind": "github"},
help_text="User-scoped GitHub integration used for user-authored task runs",
+ related_name="+",
)
repository = models.CharField(
@@ -2144,7 +2148,7 @@ class TaskRun(models.Model):
# nosemgrep: prefer-uuid7-django-pk -- TODO: migrate to uuid7 or clarify intent
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
task = models.ForeignKey(Task, on_delete=models.CASCADE, related_name="runs")
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
# Copy of the parent task's origin_product, populated on creation and never changed.
# It lets the per-minute monitoring gauges group by origin_product without joining
# posthog_task on every run row. See `collect_task_run_state_metrics`.
@@ -3129,7 +3133,9 @@ class TaskWorkflowDispatch(TeamScopedRootMixin):
DEAD = "dead", "dead"
id = models.UUIDField(primary_key=True, default=uuid7, editable=False)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, db_index=False)
+ team = models.ForeignKey(
+ "posthog.Team", on_delete=models.CASCADE, db_constraint=False, db_index=False, related_name="+"
+ )
task_run = models.ForeignKey(TaskRun, on_delete=models.CASCADE, related_name="workflow_dispatches", db_index=False)
workflow_id = models.CharField(max_length=512)
dispatch_kind = models.CharField(max_length=16, choices=Kind.choices)
@@ -3551,8 +3557,8 @@ class SandboxEnvironment(UUIDModel):
FULL = "full", "Full"
CUSTOM = "custom", "Custom"
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
- created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
+ created_by = models.ForeignKey("posthog.User", on_delete=models.SET_NULL, null=True, blank=True, related_name="+")
name = models.CharField(max_length=255)
@@ -3777,10 +3783,7 @@ class SandboxCustomImage(TeamScopedRootMixin):
class DesktopBetaTermsAcceptance(models.Model):
organization = models.OneToOneField(
- "posthog.Organization",
- on_delete=models.CASCADE,
- primary_key=True,
- db_constraint=False,
+ "posthog.Organization", on_delete=models.CASCADE, primary_key=True, db_constraint=False, related_name="+"
)
accepted_by_user_id = models.BigIntegerField()
accepted_at = models.DateTimeField(auto_now_add=True)
diff --git a/products/tracing/backend/migrations/0005_alter_teamtracingconfig_team_and_more.py b/products/tracing/backend/migrations/0005_alter_teamtracingconfig_team_and_more.py
new file mode 100644
index 000000000000..a96dc30dfb0a
--- /dev/null
+++ b/products/tracing/backend/migrations/0005_alter_teamtracingconfig_team_and_more.py
@@ -0,0 +1,50 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ("tracing", "0004_squash_2026_09_07_schema_addons"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="teamtracingconfig",
+ name="team",
+ field=models.OneToOneField(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ primary_key=True,
+ related_name="+",
+ serialize=False,
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="tracingview",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="tracingview",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/tracing/backend/migrations/max_migration.txt b/products/tracing/backend/migrations/max_migration.txt
index 575a4a91bf31..f12191ab5556 100644
--- a/products/tracing/backend/migrations/max_migration.txt
+++ b/products/tracing/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0004_squash_2026_09_07_schema_addons
+0005_alter_teamtracingconfig_team_and_more
diff --git a/products/tracing/backend/models.py b/products/tracing/backend/models.py
index 02146e5e702d..0f26f8c420d5 100644
--- a/products/tracing/backend/models.py
+++ b/products/tracing/backend/models.py
@@ -51,7 +51,9 @@ class TeamTracingConfig(models.Model):
# db_constraint=False so creating this table takes no lock on the hot posthog_team
# parent; the real constraint is added lock-free via AddForeignKeyNotValid in the
# migration, same as TracingView.
- team = models.OneToOneField("posthog.Team", on_delete=models.CASCADE, primary_key=True, db_constraint=False)
+ team = models.OneToOneField(
+ "posthog.Team", on_delete=models.CASCADE, primary_key=True, db_constraint=False, related_name="+"
+ )
# Span or resource attribute keys whose values match a PostHog person's distinct_id —
# a span links to a person when any of these attributes holds their distinct ID.
@@ -84,9 +86,9 @@ class TracingView(TeamScopedRootMixin, UUIDModel, CreatedMetaFields, UpdatedMeta
# FKs to the hot posthog_team / posthog_user tables use db_constraint=False so creating this
# table takes no lock on those parents; the real constraints are added lock-free via
# AddForeignKeyNotValid in the migration. created_by overrides CreatedMetaFields for the same reason.
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
# Human-friendly id used in the API/URL instead of exposing the UUID primary key.
short_id = models.CharField(max_length=12, blank=True, default=generate_short_id)
diff --git a/products/user_interviews/backend/migrations/0010_alter_intervieweecontext_team_and_more.py b/products/user_interviews/backend/migrations/0010_alter_intervieweecontext_team_and_more.py
new file mode 100644
index 000000000000..565d336a3533
--- /dev/null
+++ b/products/user_interviews/backend/migrations/0010_alter_intervieweecontext_team_and_more.py
@@ -0,0 +1,41 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ("user_interviews", "0009_userinterview_shared_respondent_fields"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="intervieweecontext",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="userinterview",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="userinterviewtopic",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/user_interviews/backend/migrations/max_migration.txt b/products/user_interviews/backend/migrations/max_migration.txt
index 470197bc8934..328e4d7435bf 100644
--- a/products/user_interviews/backend/migrations/max_migration.txt
+++ b/products/user_interviews/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0009_userinterview_shared_respondent_fields
+0010_alter_intervieweecontext_team_and_more
diff --git a/products/user_interviews/backend/models.py b/products/user_interviews/backend/models.py
index c161d2e203c7..730f46d395c3 100644
--- a/products/user_interviews/backend/models.py
+++ b/products/user_interviews/backend/models.py
@@ -29,7 +29,7 @@ class UserInterviewClassification(models.TextChoices):
class UserInterview(UUIDTModel, CreatedMetaFields):
- team = models.ForeignKey(Team, on_delete=models.CASCADE)
+ team = models.ForeignKey(Team, on_delete=models.CASCADE, related_name="+")
interviewee_emails = ArrayField(
models.CharField(max_length=254, validators=[EmailWithDisplayNameValidator()]), default=list
)
@@ -75,7 +75,7 @@ class UserInterview(UUIDTModel, CreatedMetaFields):
class UserInterviewTopic(UUIDTModel, CreatedMetaFields):
- team = models.ForeignKey(Team, on_delete=models.CASCADE)
+ team = models.ForeignKey(Team, on_delete=models.CASCADE, related_name="+")
interviewee_emails = ArrayField(
models.CharField(max_length=254, validators=[EmailWithDisplayNameValidator()]),
default=list,
@@ -101,7 +101,7 @@ class UserInterviewTopic(UUIDTModel, CreatedMetaFields):
class IntervieweeContext(UUIDTModel, CreatedMetaFields):
- team = models.ForeignKey(Team, on_delete=models.CASCADE)
+ team = models.ForeignKey(Team, on_delete=models.CASCADE, related_name="+")
topic = models.ForeignKey(
UserInterviewTopic,
on_delete=models.CASCADE,
diff --git a/products/warehouse_sources/backend/migrations/0161_alter_customoauth2integration_created_by_and_more.py b/products/warehouse_sources/backend/migrations/0161_alter_customoauth2integration_created_by_and_more.py
new file mode 100644
index 000000000000..37d884c9c3f5
--- /dev/null
+++ b/products/warehouse_sources/backend/migrations/0161_alter_customoauth2integration_created_by_and_more.py
@@ -0,0 +1,178 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ("warehouse_sources", "0160_datawarehousetable_dwtable_team_live_created"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="customoauth2integration",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="customoauth2integration",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datawarehousecredential",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="datawarehousetable",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="externaldatadestination",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="externaldatadestination",
+ name="integration",
+ field=models.ForeignKey(
+ blank=True,
+ help_text="Credentials for this destination. Null for the PostHog warehouse.",
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to="posthog.integration",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="externaldatadestination",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="externaldatajob",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="externaldataschemadestination",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="externaldataschemaoomevent",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="externaldatasource",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="externaldatasourcedestination",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="pendingsourcecredential",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="warehousecolumnannotation",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="warehousecolumnstatistics",
+ name="created_by",
+ field=models.ForeignKey(
+ blank=True,
+ db_constraint=False,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="warehousecolumnstatistics",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ ]
diff --git a/products/warehouse_sources/backend/migrations/max_migration.txt b/products/warehouse_sources/backend/migrations/max_migration.txt
index 4c371aefe89a..2a3b7988e213 100644
--- a/products/warehouse_sources/backend/migrations/max_migration.txt
+++ b/products/warehouse_sources/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0160_datawarehousetable_dwtable_team_live_created
+0161_alter_customoauth2integration_created_by_and_more
diff --git a/products/warehouse_sources/backend/models/column_annotation.py b/products/warehouse_sources/backend/models/column_annotation.py
index a78e6d9cd412..289d63c7d28a 100644
--- a/products/warehouse_sources/backend/models/column_annotation.py
+++ b/products/warehouse_sources/backend/models/column_annotation.py
@@ -19,7 +19,7 @@ class WarehouseColumnAnnotation(TeamScopedRootMixin, CreatedMetaFields, UpdatedM
# Kept on the model so the nested names and the `choices=` below stay unchanged.
DescriptionSource = WarehouseColumnAnnotationDescriptionSource
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
table = models.ForeignKey(
"warehouse_sources.DataWarehouseTable", on_delete=models.CASCADE, related_name="column_annotations"
)
diff --git a/products/warehouse_sources/backend/models/column_statistics.py b/products/warehouse_sources/backend/models/column_statistics.py
index 9ebd53659901..354338450f03 100644
--- a/products/warehouse_sources/backend/models/column_statistics.py
+++ b/products/warehouse_sources/backend/models/column_statistics.py
@@ -23,9 +23,9 @@ class WarehouseColumnStatistics(TeamScopedRootMixin, CreatedMetaFields, UpdatedM
# constraint takes a SHARE ROW EXCLUSIVE lock on the parent, which stalls under write traffic. Team
# scoping is enforced at the app level by TeamScopedRootMixin, and these are derived rows, so we don't
# need DB-level referential integrity here. The table FK targets a non-hot table, so it keeps its constraint.
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
table = models.ForeignKey(
"warehouse_sources.DataWarehouseTable", on_delete=models.CASCADE, related_name="column_statistics"
diff --git a/products/warehouse_sources/backend/models/credential.py b/products/warehouse_sources/backend/models/credential.py
index 7459f67168d0..d630f1da68b1 100644
--- a/products/warehouse_sources/backend/models/credential.py
+++ b/products/warehouse_sources/backend/models/credential.py
@@ -8,7 +8,7 @@ from posthog.sync import database_sync_to_async
class DataWarehouseCredential(CreatedMetaFields, UUIDTModel):
access_key = EncryptedTextField(max_length=500)
access_secret = EncryptedTextField(max_length=500)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
__repr__ = sane_repr("access_key")
diff --git a/products/warehouse_sources/backend/models/custom_oauth2_integration.py b/products/warehouse_sources/backend/models/custom_oauth2_integration.py
index bd1465123718..e889331e04f2 100644
--- a/products/warehouse_sources/backend/models/custom_oauth2_integration.py
+++ b/products/warehouse_sources/backend/models/custom_oauth2_integration.py
@@ -58,9 +58,9 @@ class CustomOAuth2Integration(TeamScopedRootMixin, CreatedMetaFields, UpdatedMet
# constraint takes a SHARE ROW EXCLUSIVE lock on the parent, which stalls under write traffic. Team
# scoping is enforced at the app level by TeamScopedRootMixin. The external_data_source FK targets a
# non-hot table, so it keeps its constraint (and its cascade cleans the row up when the source is deleted).
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
external_data_source = models.ForeignKey(
"warehouse_sources.ExternalDataSource",
diff --git a/products/warehouse_sources/backend/models/external_data_destination.py b/products/warehouse_sources/backend/models/external_data_destination.py
index 8bd0f8441609..3129ccce6766 100644
--- a/products/warehouse_sources/backend/models/external_data_destination.py
+++ b/products/warehouse_sources/backend/models/external_data_destination.py
@@ -32,7 +32,7 @@ class ExternalDataDestination(TeamScopedRootMixin, UpdatedMetaFields, DeletedMet
# take a lock on it while being created. Team scoping is enforced at the app level
# via `TeamScopedRootMixin`. See products/README.md "Adding or moving backend models
# and migrations".
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
type = models.CharField(max_length=64, choices=Type)
name = models.CharField(max_length=400)
config = models.JSONField(
@@ -45,11 +45,12 @@ class ExternalDataDestination(TeamScopedRootMixin, UpdatedMetaFields, DeletedMet
on_delete=models.SET_NULL,
null=True,
blank=True,
+ related_name="+",
help_text="Credentials for this destination. Null for the PostHog warehouse.",
)
# `db_constraint=False`: `posthog_user` is a hot table, same reasoning as `team`.
created_by = models.ForeignKey(
- "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False
+ "posthog.User", on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False, related_name="+"
)
created_at = models.DateTimeField(auto_now_add=True)
@@ -77,7 +78,7 @@ class ExternalDataDestination(TeamScopedRootMixin, UpdatedMetaFields, DeletedMet
class ExternalDataSourceDestination(TeamScopedRootMixin, UpdatedMetaFields, UUIDTModel):
"""Source-level default destination set, inherited by every schema that does not override it."""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
source = models.ForeignKey(
"warehouse_sources.ExternalDataSource", on_delete=models.CASCADE, related_name="destination_links"
)
@@ -104,7 +105,7 @@ class ExternalDataSchemaDestination(TeamScopedRootMixin, UpdatedMetaFields, UUID
mirroring how `ExternalDataSchema.api_version` overrides the source pin.
"""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
schema = models.ForeignKey(
"warehouse_sources.ExternalDataSchema", on_delete=models.CASCADE, related_name="destination_links"
)
diff --git a/products/warehouse_sources/backend/models/external_data_job.py b/products/warehouse_sources/backend/models/external_data_job.py
index 39e838bd75bd..a97b7b5745c5 100644
--- a/products/warehouse_sources/backend/models/external_data_job.py
+++ b/products/warehouse_sources/backend/models/external_data_job.py
@@ -18,7 +18,7 @@ class ExternalDataJob(CreatedMetaFields, UpdatedMetaFields, UUIDTModel):
Status = ExternalDataJobStatus
PipelineVersion = ExternalDataJobPipelineVersion
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
pipeline = models.ForeignKey("warehouse_sources.ExternalDataSource", related_name="jobs", on_delete=models.CASCADE)
schema = models.ForeignKey("warehouse_sources.ExternalDataSchema", on_delete=models.CASCADE, null=True, blank=True)
status = models.CharField(max_length=400)
diff --git a/products/warehouse_sources/backend/models/external_data_source.py b/products/warehouse_sources/backend/models/external_data_source.py
index a1dba2fc463d..487cc03e70d9 100644
--- a/products/warehouse_sources/backend/models/external_data_source.py
+++ b/products/warehouse_sources/backend/models/external_data_source.py
@@ -47,7 +47,7 @@ class ExternalDataSource(ModelActivityMixin, CreatedMetaFields, UpdatedMetaField
source_id = models.CharField(max_length=400)
connection_id = models.CharField(max_length=400)
destination_id = 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="+")
# Deprecated, use `ExternalDataSchema.sync_frequency_interval`
sync_frequency = models.CharField(max_length=128, choices=SyncFrequency, default=SyncFrequency.DAILY, blank=True)
diff --git a/products/warehouse_sources/backend/models/oom_event.py b/products/warehouse_sources/backend/models/oom_event.py
index 5c925ea19cce..c8ee8a9c0966 100644
--- a/products/warehouse_sources/backend/models/oom_event.py
+++ b/products/warehouse_sources/backend/models/oom_event.py
@@ -59,7 +59,7 @@ class ExternalDataSchemaOOMEvent(TeamScopedRootMixin, UUIDModel):
# db_constraint=False on the Team FK: a real constraint takes a SHARE ROW EXCLUSIVE lock on the
# hot posthog_team table on create. Team scoping is enforced at the app layer by TeamScopedRootMixin.
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
schema = models.ForeignKey(
"warehouse_sources.ExternalDataSchema", on_delete=models.CASCADE, related_name="oom_events"
)
diff --git a/products/warehouse_sources/backend/models/pending_source_credential.py b/products/warehouse_sources/backend/models/pending_source_credential.py
index 58aa4a723d1f..df291b942f39 100644
--- a/products/warehouse_sources/backend/models/pending_source_credential.py
+++ b/products/warehouse_sources/backend/models/pending_source_credential.py
@@ -24,7 +24,7 @@ class PendingSourceCredential(TeamScopedRootMixin, CreatedMetaFields, UUIDTModel
soon as the source is created, and ignored/purged after `expires_at` if never consumed.
"""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
source_type = models.CharField(max_length=128, choices=external_data_source_type_choices)
payload = EncryptedJSONField(default=dict)
expires_at = models.DateTimeField(default=pending_credential_default_expiry)
diff --git a/products/warehouse_sources/backend/models/table.py b/products/warehouse_sources/backend/models/table.py
index 96a2579e528d..229ca047348b 100644
--- a/products/warehouse_sources/backend/models/table.py
+++ b/products/warehouse_sources/backend/models/table.py
@@ -307,7 +307,7 @@ class DataWarehouseTable(CreatedMetaFields, UpdatedMetaFields, UUIDTModel, Delet
name = models.CharField(max_length=128)
format = models.CharField(max_length=128, choices=TableFormat)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
url_pattern = models.CharField(max_length=500)
queryable_folder = models.CharField(max_length=500, null=True, blank=True)
diff --git a/products/web_analytics/backend/migrations/0012_alter_savedheatmap_created_by_and_more.py b/products/web_analytics/backend/migrations/0012_alter_savedheatmap_created_by_and_more.py
new file mode 100644
index 000000000000..ac04d6223ac6
--- /dev/null
+++ b/products/web_analytics/backend/migrations/0012_alter_savedheatmap_created_by_and_more.py
@@ -0,0 +1,132 @@
+# Generated by Django 5.2.17 on 2026-09-10 07:32
+
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1350_alter_userscenepersonalisation_dashboard"),
+ ("web_analytics", "0011_contentautopilotsiteprofile_deleted"),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="savedheatmap",
+ 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="savedheatmap",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="webanalyticsachievementprogress",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="webanalyticsachievementprogress",
+ name="user",
+ field=models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="webanalyticsfilterpreset",
+ 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="webanalyticsfilterpreset",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="webanalyticsinteraction",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="webanalyticsinteraction",
+ name="user",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="webanalyticsuserconfig",
+ name="team",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="webanalyticsuserconfig",
+ name="user",
+ field=models.ForeignKey(
+ db_constraint=False,
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ migrations.AlterField(
+ model_name="webanalyticsvisit",
+ name="team",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to="posthog.team",
+ ),
+ ),
+ migrations.AlterField(
+ model_name="webanalyticsvisit",
+ name="user",
+ field=models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="+",
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ]
diff --git a/products/web_analytics/backend/migrations/max_migration.txt b/products/web_analytics/backend/migrations/max_migration.txt
index d39fd2b99d75..0ae77494427d 100644
--- a/products/web_analytics/backend/migrations/max_migration.txt
+++ b/products/web_analytics/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0011_contentautopilotsiteprofile_deleted
+0012_alter_savedheatmap_created_by_and_more
diff --git a/products/web_analytics/backend/models/heatmap_saved.py b/products/web_analytics/backend/models/heatmap_saved.py
index 44fd19a15b0c..a2fc66de718c 100644
--- a/products/web_analytics/backend/models/heatmap_saved.py
+++ b/products/web_analytics/backend/models/heatmap_saved.py
@@ -21,7 +21,7 @@ class SavedHeatmap(UUIDTModel):
short_id = models.CharField(max_length=12, blank=True, default=generate_short_id)
name = 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="+")
url = models.URLField(max_length=2000)
data_url = models.URLField(max_length=2000, null=True, blank=True, help_text="URL for fetching heatmap data")
# Planned widths to generate for screenshot-type heatmaps
@@ -37,7 +37,7 @@ class SavedHeatmap(UUIDTModel):
# Metadata
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=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="+")
# Error handling
exception = models.TextField(null=True, blank=True)
diff --git a/products/web_analytics/backend/models/web_analytics_achievement_progress.py b/products/web_analytics/backend/models/web_analytics_achievement_progress.py
index 4fb05aa6b87b..ab25724e89d4 100644
--- a/products/web_analytics/backend/models/web_analytics_achievement_progress.py
+++ b/products/web_analytics/backend/models/web_analytics_achievement_progress.py
@@ -11,8 +11,8 @@ class WebAnalyticsAchievementProgress(TeamScopedRootMixin, UUIDModel):
detail: `unlocked_stages` (stage -> ISO timestamp), `pending_celebrations` (stages awaiting a
client acknowledge), and `streak` (`last_visit_date`, `grace_used`)."""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
- user = models.ForeignKey("posthog.User", on_delete=models.CASCADE, null=True, blank=True)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
+ user = models.ForeignKey("posthog.User", on_delete=models.CASCADE, null=True, blank=True, related_name="+")
track_key = models.CharField(max_length=64)
current_stage = models.PositiveSmallIntegerField(default=0)
progress_value = models.BigIntegerField(default=0)
diff --git a/products/web_analytics/backend/models/web_analytics_filter_preset.py b/products/web_analytics/backend/models/web_analytics_filter_preset.py
index 2d458c51eddc..914315ce667f 100644
--- a/products/web_analytics/backend/models/web_analytics_filter_preset.py
+++ b/products/web_analytics/backend/models/web_analytics_filter_preset.py
@@ -9,12 +9,12 @@ class WebAnalyticsFilterPreset(UUIDModel):
short_id = models.CharField(max_length=12, blank=True, default=generate_short_id)
name = models.CharField(max_length=400)
description = models.TextField(blank=True)
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
pinned = models.BooleanField(default=False)
deleted = models.BooleanField(default=False)
filters = models.JSONField(default=dict)
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="+")
last_modified_at = models.DateTimeField(default=timezone.now)
last_modified_by = models.ForeignKey(
"posthog.User",
diff --git a/products/web_analytics/backend/models/web_analytics_interaction.py b/products/web_analytics/backend/models/web_analytics_interaction.py
index 35429d2cc40f..c9681d9cdfc2 100644
--- a/products/web_analytics/backend/models/web_analytics_interaction.py
+++ b/products/web_analytics/backend/models/web_analytics_interaction.py
@@ -14,8 +14,8 @@ class WebAnalyticsInteraction(TeamScopedRootMixin, UUIDModel):
RECORDING = "recording"
KIND_CHOICES = [(DATA, "data"), (RECORDING, "recording")]
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
- user = models.ForeignKey("posthog.User", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
+ user = models.ForeignKey("posthog.User", on_delete=models.CASCADE, related_name="+")
kind = models.CharField(max_length=32, choices=KIND_CHOICES)
count = models.BigIntegerField(default=0)
updated_at = models.DateTimeField(auto_now=True)
diff --git a/products/web_analytics/backend/models/web_analytics_user_config.py b/products/web_analytics/backend/models/web_analytics_user_config.py
index 43416ef14fd8..2ec3019bd156 100644
--- a/products/web_analytics/backend/models/web_analytics_user_config.py
+++ b/products/web_analytics/backend/models/web_analytics_user_config.py
@@ -5,8 +5,8 @@ from posthog.models.utils import UUIDModel
class WebAnalyticsUserConfig(TeamScopedRootMixin, UUIDModel):
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False)
- user = models.ForeignKey("posthog.User", on_delete=models.CASCADE, db_constraint=False)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, db_constraint=False, related_name="+")
+ user = models.ForeignKey("posthog.User", on_delete=models.CASCADE, db_constraint=False, related_name="+")
achievements_opt_out = models.BooleanField(default=False)
updated_at = models.DateTimeField(auto_now=True)
diff --git a/products/web_analytics/backend/models/web_analytics_visit.py b/products/web_analytics/backend/models/web_analytics_visit.py
index 62460d6189ae..7d234bbef02e 100644
--- a/products/web_analytics/backend/models/web_analytics_visit.py
+++ b/products/web_analytics/backend/models/web_analytics_visit.py
@@ -9,8 +9,8 @@ class WebAnalyticsVisit(TeamScopedRootMixin, UUIDModel):
truth for streak and cumulative-loyalty achievements. `visit_date` is the team-local date, not
a datetime — streak math must use the same team timezone that wrote it."""
- team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE)
- user = models.ForeignKey("posthog.User", on_delete=models.CASCADE)
+ team = models.ForeignKey("posthog.Team", on_delete=models.CASCADE, related_name="+")
+ user = models.ForeignKey("posthog.User", on_delete=models.CASCADE, related_name="+")
visit_date = models.DateField()
created_at = models.DateTimeField(auto_now_add=True)