:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(clickhouse): stop 0273 leaving query_log_archive_old off cloud (#84889)
Paweł Szczur6f4f6f82016b
diff --git a/posthog/clickhouse/migrations/0273_query_log_archive_ops_json.py b/posthog/clickhouse/migrations/0273_query_log_archive_ops_json.pyindex ec1dee05342d..babd0d3b0143 100644--- a/posthog/clickhouse/migrations/0273_query_log_archive_ops_json.py+++ b/posthog/clickhouse/migrations/0273_query_log_archive_ops_json.py@@ -1,3 +1,4 @@+from posthog import settingsfrom posthog.clickhouse.client.connection import NodeRolefrom posthog.clickhouse.client.migration_tools import run_sql_with_exceptionsfrom posthog.clickhouse.query_log_archive import (@@ -7,6 +8,7 @@ from posthog.clickhouse.query_log_archive import (QUERY_LOG_ARCHIVE_OPS_MV_SQL,SHARDED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL,SHARDED_QUERY_LOG_ARCHIVE_TABLE,+ SHARDED_QUERY_LOG_ARCHIVE_WRITABLE_TABLE,WRITABLE_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL,WRITABLE_QUERY_LOG_ARCHIVE_TABLE,)@@ -59,6 +61,23 @@ operations = [f"RENAME TABLE IF EXISTS {QUERY_LOG_ARCHIVE_DATA_TABLE} TO {QUERY_LOG_ARCHIVE_OLD_TABLE}",node_roles=[NodeRole.OPS],),+ # Only cloud has data to backfill. Off cloud the rename above is either a no-op (OPS+ # carries no query_log_archive until step H creates it) or, where every role shares one+ # node, it catches the DATA-side table and leaves an empty copy behind — so drop it.+ *(+ []+ if settings.CLOUD_DEPLOYMENT in ("US", "EU", "DEV")+ else [+ run_sql_with_exceptions(+ f"DROP TABLE IF EXISTS {QUERY_LOG_ARCHIVE_OLD_TABLE}",+ node_roles=[NodeRole.OPS],+ ),+ run_sql_with_exceptions(+ f"DROP TABLE IF EXISTS {SHARDED_QUERY_LOG_ARCHIVE_WRITABLE_TABLE}",+ node_roles=[NodeRole.ENDPOINTS],+ ),+ ]+ ),# ---------- C. New JSON-backed data table on OPS ----------run_sql_with_exceptions(SHARDED_QUERY_LOG_ARCHIVE_OPS_TABLE_SQL(), node_roles=[NodeRole.OPS]),# ---------- D. Writable Distributed (physical columns only) -> ops.sharded, on every cluster ----------