:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(cdp): re-assert hog_invocation_results data table in migration 0258 (#59594)
Ben Whitef71adb49b317
diff --git a/posthog/clickhouse/migrations/0258_hog_invocation_results_warpstream_cyclotron.py b/posthog/clickhouse/migrations/0258_hog_invocation_results_warpstream_cyclotron.pyindex 3628b0f8cc60..7557d0d474f6 100644--- a/posthog/clickhouse/migrations/0258_hog_invocation_results_warpstream_cyclotron.py+++ b/posthog/clickhouse/migrations/0258_hog_invocation_results_warpstream_cyclotron.py@@ -1,18 +1,32 @@from posthog.clickhouse.client.connection import NodeRolefrom posthog.clickhouse.client.migration_tools import run_sql_with_exceptionsfrom posthog.models.hog_invocation_results.sql import (+ DISTRIBUTED_HOG_INVOCATION_RESULTS_TABLE_SQL,DROP_HOG_INVOCATION_RESULTS_MV_SQL,DROP_KAFKA_HOG_INVOCATION_RESULTS_TABLE_SQL,+ HOG_INVOCATION_RESULTS_DATA_TABLE_SQL,HOG_INVOCATION_RESULTS_MV_SQL,KAFKA_HOG_INVOCATION_RESULTS_TABLE_SQL,)# Repoint the hog_invocation_results Kafka engine table from the warpstream-shared-# named collection to warpstream-cyclotron. The CDP producer writes lifecycle+# named collection to warpstream-cyclotron — the CDP producer writes lifecycle# rows to the cyclotron Warpstream cluster, so ClickHouse must consume from the-# same cluster. The Kafka engine table and MV are non-replicated, so a plain-# drop + recreate is safe (no SYNC needed); the data table is untouched.+# same cluster.+#+# The Kafka engine table + MV are non-replicated, so they're dropped and+# recreated outright (no SYNC needed). The data table and distributed read+# alias are re-asserted with CREATE ... IF NOT EXISTS first: 0254 creates them,+# but a cluster that lost its AUX local tables (e.g. a rebuilt dev AUX cluster)+# still has 0254 recorded as applied — leaving the MV recreate below to fail+# with "table does not exist". IF NOT EXISTS makes the re-assert a no-op+# wherever the tables are already present.operations = [+ # Ensure the local data table the MV targets exists.+ run_sql_with_exceptions(+ HOG_INVOCATION_RESULTS_DATA_TABLE_SQL(),+ node_roles=[NodeRole.AUX],+ ),# Drop the MV first — it reads from the Kafka engine table.run_sql_with_exceptions(DROP_HOG_INVOCATION_RESULTS_MV_SQL(),@@ -32,4 +46,9 @@ operations = [HOG_INVOCATION_RESULTS_MV_SQL(),node_roles=[NodeRole.AUX],),+ # Ensure the distributed read alias exists (HogQL queries resolve through it).+ run_sql_with_exceptions(+ DISTRIBUTED_HOG_INVOCATION_RESULTS_TABLE_SQL(),+ node_roles=[NodeRole.AUX, NodeRole.DATA],+ ),]