Skip to content

Commit 211c6e7

Browse files
macoboposthog-bot
andauthored
Add migration for distinct_id column on clickhouse person table (#5276)
* Add migration for `distinct_id` column on clickhouse Note that code under ee/clickhouse/models/person.py does not work anymore since it does not populate the column correctly. That is fine - will be handled when doing the actual migration, rather than for this experiment. * Update plugin server to 1.1.8 Co-authored-by: posthog-bot <[email protected]>
1 parent e1a2420 commit 211c6e7

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from infi.clickhouse_orm import migrations
2+
3+
from ee.clickhouse.sql.person import KAFKA_PERSONS_TABLE_SQL, PERSONS_TABLE_MV_SQL
4+
from posthog.settings import CLICKHOUSE_CLUSTER
5+
6+
operations = [
7+
migrations.RunSQL(f"DROP TABLE person_mv ON CLUSTER {CLICKHOUSE_CLUSTER}"),
8+
migrations.RunSQL(f"DROP TABLE kafka_person ON CLUSTER {CLICKHOUSE_CLUSTER}"),
9+
migrations.RunSQL(
10+
f"ALTER TABLE person ON CLUSTER {CLICKHOUSE_CLUSTER} ADD COLUMN IF NOT EXISTS distinct_ids Array(VARCHAR)"
11+
),
12+
migrations.RunSQL(KAFKA_PERSONS_TABLE_SQL),
13+
migrations.RunSQL(PERSONS_TABLE_MV_SQL),
14+
]

ee/clickhouse/sql/person.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
team_id Int64,
1818
properties VARCHAR,
1919
is_identified Boolean,
20+
distinct_ids Array(VARCHAR),
2021
is_deleted Boolean DEFAULT 0
2122
{extra_fields}
2223
) ENGINE = {engine}
@@ -50,6 +51,7 @@
5051
team_id,
5152
properties,
5253
is_identified,
54+
distinct_ids,
5355
is_deleted,
5456
_timestamp,
5557
_offset

plugins/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"license": "MIT",
55
"private": true,
66
"dependencies": {
7-
"@posthog/plugin-server": "1.1.7"
7+
"@posthog/plugin-server": "1.1.8"
88
},
99
"scripts": {
1010
"start": "posthog-plugin-server"

plugins/yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,10 +1009,10 @@
10091009
resolved "https://registry.yarnpkg.com/@posthog/plugin-scaffold/-/plugin-scaffold-0.12.5.tgz#596539ea69df21f07640a2ce0a335c7ead940b06"
10101010
integrity sha512-EuRoYM17vYI1m2SmXpYe7LC9hFPWsRnN6rAi6q3unFIW26pT40sV/TYSWnBEihZXIWdVShwiGXORQMHjpnJOig==
10111011

1012-
"@posthog/[email protected].7":
1013-
version "1.1.7"
1014-
resolved "https://registry.yarnpkg.com/@posthog/plugin-server/-/plugin-server-1.1.7.tgz#d7c93d87e8709f3577ffc05eaa5aa17346db5487"
1015-
integrity sha512-F0Vl3FVF/MaE803Jyxs6Qb0tg5qQUkKCrvf+brBqc4bEviK1SD73XUngBMl8TJY1xlfC+5H4ZnPNhjWZUEjLJw==
1012+
"@posthog/[email protected].8":
1013+
version "1.1.8"
1014+
resolved "https://registry.yarnpkg.com/@posthog/plugin-server/-/plugin-server-1.1.8.tgz#672277bd508bb4f185b97d3f259d83eccd3555c3"
1015+
integrity sha512-TY9bN3scd9TR2koOGItq0xR+qF6mf2GVx80zngqp0OcSD+Tys+RX2u8mos2dXWfoHscBVcFOXNAEqgG4+H4i5g==
10161016
dependencies:
10171017
"@babel/core" "^7.13.1"
10181018
"@babel/preset-env" "^7.13.5"

0 commit comments

Comments
 (0)