0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 12:21:02 +01:00
posthog/ee/clickhouse/migrations/0013_persons_distinct_ids_column.py
Karl-Aksel Puulmann 211c6e762f
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 <posthog-bot@users.noreply.github.com>
2021-07-22 14:30:12 +03:00

15 lines
594 B
Python

from infi.clickhouse_orm import migrations
from ee.clickhouse.sql.person import KAFKA_PERSONS_TABLE_SQL, PERSONS_TABLE_MV_SQL
from posthog.settings import CLICKHOUSE_CLUSTER
operations = [
migrations.RunSQL(f"DROP TABLE person_mv ON CLUSTER {CLICKHOUSE_CLUSTER}"),
migrations.RunSQL(f"DROP TABLE kafka_person ON CLUSTER {CLICKHOUSE_CLUSTER}"),
migrations.RunSQL(
f"ALTER TABLE person ON CLUSTER {CLICKHOUSE_CLUSTER} ADD COLUMN IF NOT EXISTS distinct_ids Array(VARCHAR)"
),
migrations.RunSQL(KAFKA_PERSONS_TABLE_SQL),
migrations.RunSQL(PERSONS_TABLE_MV_SQL),
]