Skip to content

Commit

Permalink
Add the column to the events table as well
Browse files Browse the repository at this point in the history
  • Loading branch information
fuziontech committed Aug 26, 2024
1 parent 910739f commit e99af8b
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -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
Expand All @@ -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))


Expand Down

0 comments on commit e99af8b

Please sign in to comment.