From e99af8b09de4c07a74a706b7408aaa1989cd9a05 Mon Sep 17 00:00:00 2001 From: James Greenhill Date: Mon, 26 Aug 2024 14:23:12 -0700 Subject: [PATCH] Add the column to the events table as well --- .../0078_add_soft_delete_column_on_events.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/posthog/clickhouse/migrations/0078_add_soft_delete_column_on_events.py b/posthog/clickhouse/migrations/0078_add_soft_delete_column_on_events.py index 44e7c5deee802..1450b452f9bbd 100644 --- a/posthog/clickhouse/migrations/0078_add_soft_delete_column_on_events.py +++ b/posthog/clickhouse/migrations/0078_add_soft_delete_column_on_events.py @@ -4,7 +4,7 @@ from posthog.settings import CLICKHOUSE_CLUSTER -DROP_COLUMNS_SHARDED_EVENTS = """ +DROP_COLUMNS_EVENTS = """ ALTER TABLE {table} ON CLUSTER {cluster} DROP COLUMN IF EXISTS is_deleted """ @@ -14,6 +14,11 @@ ADD COLUMN IF NOT EXISTS is_deleted DEFAULT Boolean False """ +ADD_COLUMNS_EVENTS = """ +ALTER TABLE {table} ON CLUSTER {cluster} +ADD COLUMN IF NOT EXISTS is_deleted +""" + ADD_COLUMNS_INDEX_EVENTS = """ ALTER TABLE {table} ON CLUSTER {cluster} ADD INDEX IF NOT EXISTS is_deleted_idx (is_deleted) TYPE minmax GRANULARITY 1 @@ -22,8 +27,10 @@ def add_columns_to_required_tables(_): with ch_pool.get_client() as client: - client.execute(DROP_COLUMNS_SHARDED_EVENTS.format(table="sharded_events", cluster=CLICKHOUSE_CLUSTER)) + client.execute(DROP_COLUMNS_EVENTS.format(table="sharded_events", cluster=CLICKHOUSE_CLUSTER)) + client.execute(DROP_COLUMNS_EVENTS.format(table="events", cluster=CLICKHOUSE_CLUSTER)) client.execute(ADD_COLUMNS_SHARDED_EVENTS.format(table="sharded_events", cluster=CLICKHOUSE_CLUSTER)) + client.execute(ADD_COLUMNS_EVENTS.format(table="events", cluster=CLICKHOUSE_CLUSTER)) client.execute(ADD_COLUMNS_INDEX_EVENTS.format(table="sharded_events", cluster=CLICKHOUSE_CLUSTER))