-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add person_mode column to CH events table
- Loading branch information
1 parent
d929ca9
commit 2531c01
Showing
3 changed files
with
40 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from infi.clickhouse_orm import migrations | ||
|
||
from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions | ||
from posthog.client import sync_execute | ||
from posthog.models.event.sql import ( | ||
EVENTS_TABLE_JSON_MV_SQL, | ||
KAFKA_EVENTS_TABLE_JSON_SQL, | ||
) | ||
from posthog.settings import CLICKHOUSE_CLUSTER | ||
|
||
|
||
ADD_COLUMNS_BASE_SQL = """ | ||
ALTER TABLE {table} ON CLUSTER {cluster} | ||
ADD COLUMN IF NOT EXISTS person_mode Enum8('full' = 0, 'propertyless' = 1) DEFAULT 'full' | ||
""" | ||
|
||
|
||
def add_columns_to_required_tables(_): | ||
sync_execute(ADD_COLUMNS_BASE_SQL.format(table="events", cluster=CLICKHOUSE_CLUSTER)) | ||
sync_execute(ADD_COLUMNS_BASE_SQL.format(table="writable_events", cluster=CLICKHOUSE_CLUSTER)) | ||
sync_execute(ADD_COLUMNS_BASE_SQL.format(table="sharded_events", cluster=CLICKHOUSE_CLUSTER)) | ||
|
||
|
||
operations = [ | ||
run_sql_with_exceptions(f"DROP TABLE IF EXISTS events_json_mv ON CLUSTER '{CLICKHOUSE_CLUSTER}'"), | ||
run_sql_with_exceptions(f"DROP TABLE IF EXISTS kafka_events_json ON CLUSTER '{CLICKHOUSE_CLUSTER}'"), | ||
migrations.RunPython(add_columns_to_required_tables), | ||
run_sql_with_exceptions(KAFKA_EVENTS_TABLE_JSON_SQL()), | ||
run_sql_with_exceptions(EVENTS_TABLE_JSON_MV_SQL()), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters