: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(experiments): re-apply metric_events preaggregated table creation (#60590)
Lucas Ricoy5f54dd9d2fff
diff --git a/posthog/clickhouse/migrations/0269_ensure_metric_events_preaggregated.py b/posthog/clickhouse/migrations/0269_ensure_metric_events_preaggregated.pynew file mode 100644index 000000000000..c60d4c9f72a5--- /dev/null+++ b/posthog/clickhouse/migrations/0269_ensure_metric_events_preaggregated.py@@ -0,0 +1,22 @@+from posthog.clickhouse.client.connection import NodeRole+from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions+from posthog.clickhouse.preaggregation.experiment_metric_events_sql import (+ DISTRIBUTED_EXPERIMENT_METRIC_EVENTS_TABLE_SQL,+ SHARDED_EXPERIMENT_METRIC_EVENTS_TABLE_SQL,+)++# Converges `experiment_metric_events_preaggregated` to its intended layout:+# sharded backing on AUX, query-side Distributed wrapper on AUX + DATA.+# The underlying SQL uses `CREATE TABLE IF NOT EXISTS`, so this is a no-op+# on any node that already has the table.++operations = [+ run_sql_with_exceptions(+ SHARDED_EXPERIMENT_METRIC_EVENTS_TABLE_SQL(),+ node_roles=[NodeRole.AUX],+ ),+ run_sql_with_exceptions(+ DISTRIBUTED_EXPERIMENT_METRIC_EVENTS_TABLE_SQL(),+ node_roles=[NodeRole.AUX, NodeRole.DATA],+ ),+]diff --git a/posthog/clickhouse/migrations/max_migration.txt b/posthog/clickhouse/migrations/max_migration.txtindex afa2bebe439c..eb9e1da83014 100644--- a/posthog/clickhouse/migrations/max_migration.txt+++ b/posthog/clickhouse/migrations/max_migration.txt@@ -1 +1 @@-0268_property_values_kafka_num_consumers+0269_ensure_metric_events_preaggregated