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.

fix(devex): drop forwarded index creates that a UNIQUE USING INDEX consumed (#96430)

Julian Bez451e6bce5164
diff --git a/posthog/migrations/1345_squash_2026_09_07_schema_addons.py b/posthog/migrations/1345_squash_2026_09_07_schema_addons.py
index 0bbe85037bd7..996cb9d5319a 100644
--- a/posthog/migrations/1345_squash_2026_09_07_schema_addons.py
+++ b/posthog/migrations/1345_squash_2026_09_07_schema_addons.py
@@ -152,10 +152,6 @@ class Migration(migrations.Migration):
sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_experiment_saved_metric_id_b6af2199" ON "posthog_taggeditem" ("experiment_saved_metric_id");\n ',
reverse_sql="",
),
- migrations.RunSQL(
- sql='\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_tag_id_dashboard_id_insi_734394e1_uniq" ON "posthog_taggeditem" ("tag_id", "dashboard_id", "insight_id", "event_definition_id", "property_definition_id", "action_id", "feature_flag_id", "experiment_saved_metric_id");\n ',
- reverse_sql="",
- ),
migrations.RunSQL(
sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_batchexportrun_backfill_id_9243c0f7" ON "posthog_batchexportrun" ("backfill_id");\n ',
reverse_sql="",
@@ -260,10 +256,6 @@ class Migration(migrations.Migration):
sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_ticket_id_idx"\n ON "posthog_taggeditem" ("ticket_id");\n ',
reverse_sql="",
),
- migrations.RunSQL(
- sql='\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_tag_id_dashboard_id_insi_d90686d0_uniq"\n ON "posthog_taggeditem" (\n "tag_id",\n "dashboard_id",\n "insight_id",\n "event_definition_id",\n "property_definition_id",\n "action_id",\n "feature_flag_id",\n "experiment_saved_metric_id",\n "ticket_id"\n );\n ',
- reverse_sql="",
- ),
migrations.RunSQL(
sql='\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "unique_cohort_kind_per_team"\n ON "posthog_cohort" ("team_id", "kind")\n WHERE "kind" IS NOT NULL AND "deleted" = false\n ',
reverse_sql="",
@@ -280,18 +272,10 @@ class Migration(migrations.Migration):
sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_account_id_idx"\n ON "posthog_taggeditem" ("account_id");\n ',
reverse_sql="",
),
- migrations.RunSQL(
- sql='\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_tag_id_dashboard_id_insi_4fe7898b_uniq"\n ON "posthog_taggeditem" (\n "tag_id",\n "dashboard_id",\n "insight_id",\n "event_definition_id",\n "property_definition_id",\n "action_id",\n "feature_flag_id",\n "experiment_saved_metric_id",\n "ticket_id",\n "account_id"\n );\n ',
- reverse_sql="",
- ),
migrations.RunSQL(
sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_endpoint_id_idx"\n ON "posthog_taggeditem" ("endpoint_id");\n ',
reverse_sql="",
),
- migrations.RunSQL(
- sql='\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_tag_id_dashboard_id_insi_endpoint_uniq"\n ON "posthog_taggeditem" (\n "tag_id",\n "dashboard_id",\n "insight_id",\n "event_definition_id",\n "property_definition_id",\n "action_id",\n "feature_flag_id",\n "experiment_saved_metric_id",\n "ticket_id",\n "account_id",\n "endpoint_id"\n );\n ',
- reverse_sql="",
- ),
migrations.RunSQL(
sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "cohort_team_created_idx" ON "posthog_cohort" (team_id, created_at DESC)',
reverse_sql="",
@@ -304,10 +288,6 @@ class Migration(migrations.Migration):
sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "oauthaccesstoken_scope_trgm" ON "posthog_oauthaccesstoken" USING gin (scope gin_trgm_ops) WHERE application_id IS NOT NULL',
reverse_sql="",
),
- migrations.RunSQL(
- sql='CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_identityproviderconfig_saml_relay_state_a35fb61b_uniq" ON "posthog_identityproviderconfig" (saml_relay_state)',
- reverse_sql="",
- ),
migrations.RunSQL(
sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_identityproviderconfig_saml_relay_state_a35fb61b_like" ON "posthog_identityproviderconfig" (saml_relay_state varchar_pattern_ops)',
reverse_sql="",
@@ -316,18 +296,10 @@ class Migration(migrations.Migration):
sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_replay_scanner_id_idx" ON "posthog_taggeditem" ("replay_scanner_id")',
reverse_sql="",
),
- migrations.RunSQL(
- sql='CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_tag_id_dashboard_id_insi_replay_scan_uniq" ON "posthog_taggeditem" ("tag_id", "dashboard_id", "insight_id", "event_definition_id", "property_definition_id", "action_id", "feature_flag_id", "experiment_saved_metric_id", "ticket_id", "account_id", "endpoint_id", "replay_scanner_id")',
- reverse_sql="",
- ),
migrations.RunSQL(
sql='CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_project_id_0a61d235" ON "posthog_taggeditem" ("project_id")',
reverse_sql="",
),
- migrations.RunSQL(
- sql='CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_taggeditem_tag_id_dashboard_id_insi_4ec15a8f_uniq" ON "posthog_taggeditem" ("tag_id", "dashboard_id", "insight_id", "event_definition_id", "property_definition_id", "action_id", "feature_flag_id", "experiment_saved_metric_id", "ticket_id", "account_id", "endpoint_id", "replay_scanner_id", "project_id")',
- reverse_sql="",
- ),
django.contrib.postgres.operations.ValidateConstraint(
model_name="team",
name="project_id_is_not_null",
diff --git a/products/error_tracking/backend/migrations/0033_squash_2026_09_07_schema_addons.py b/products/error_tracking/backend/migrations/0033_squash_2026_09_07_schema_addons.py
index 58447e0d19ad..621840855ae3 100644
--- a/products/error_tracking/backend/migrations/0033_squash_2026_09_07_schema_addons.py
+++ b/products/error_tracking/backend/migrations/0033_squash_2026_09_07_schema_addons.py
@@ -80,9 +80,8 @@ class Migration(migrations.Migration):
("workflows", "0001_squash_2026_09_07_initial"),
]
- operations = [
- migrations.RunSQL(
- sql='\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "idx_team_id_raw_id_part" ON "posthog_errortrackingstackframe" ("team_id", "raw_id", "part");\n ',
- reverse_sql="",
- ),
- ]
+ # The one forwarded CREATE INDEX this file carried built a duplicate of
+ # unique_team_id_raw_id_part: migration 0005 had renamed that index into
+ # the constraint. The file stays, empty, because databases record it as
+ # applied and the other schema_addons files depend on it.
+ operations = []
diff --git a/products/notebooks/backend/migrations/0019_squash_2026_09_07_schema_addons.py b/products/notebooks/backend/migrations/0019_squash_2026_09_07_schema_addons.py
index ecb1af482fd3..08874791d2d6 100644
--- a/products/notebooks/backend/migrations/0019_squash_2026_09_07_schema_addons.py
+++ b/products/notebooks/backend/migrations/0019_squash_2026_09_07_schema_addons.py
@@ -85,8 +85,4 @@ class Migration(migrations.Migration):
sql='\n CREATE INDEX CONCURRENTLY IF NOT EXISTS "posthog_resourcenotebook_account_id_idx"\n ON "posthog_resourcenotebook" ("account_id");\n ',
reverse_sql="",
),
- migrations.RunSQL(
- sql='\n CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "posthog_resourcenotebook_notebook_id_group_id_acc_7a017f67_uniq"\n ON "posthog_resourcenotebook" (\n "notebook_id",\n "group_id",\n "account_id"\n );\n ',
- reverse_sql="",
- ),
]