0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-29 03:04:16 +01:00
posthog/ee/clickhouse/models/team.py
Karl-Aksel Puulmann c2cfcb0db6
Remove hooks for person/person_distinct_id deletion (#7671)
* Make person hooks only happen in tests

* Remove a data script

* Update split_person code to handle hookless life

* Delete clickhouse data async in the background
2021-12-15 15:45:10 +02:00

32 lines
850 B
Python

import logging
from typing import List
from ee.clickhouse.client import sync_execute
from posthog.settings import CLICKHOUSE_CLUSTER
logger = logging.getLogger(__name__)
# Note: Session recording, dead letter queue, logs deletion will be handled by TTL
TABLES_TO_DELETE_FROM = [
"events",
"person",
"person_distinct_id",
"person_distinct_id2",
"groups",
"cohortpeople",
"person_static_cohort",
]
def delete_teams_data(team_ids: List[int]):
logger.info(
f"Deleting teams data from clickhouse using background mutations.",
team_ids=team_ids,
tables=TABLES_TO_DELETE_FROM,
)
for table in TABLES_TO_DELETE_FROM:
sync_execute(
f"ALTER TABLE {table} ON CLUSTER {CLICKHOUSE_CLUSTER} DELETE WHERE team_id IN %(team_ids)s",
{"team_ids": team_ids},
)