Skip to content

Commit

Permalink
Recreate data as part of resetting tables
Browse files Browse the repository at this point in the history
  • Loading branch information
robbie-c committed Dec 5, 2023
1 parent a2f4de9 commit 336acaa
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions posthog/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def create_clickhouse_tables(num_tables: int):
CREATE_DISTRIBUTED_TABLE_QUERIES,
CREATE_MERGETREE_TABLE_QUERIES,
CREATE_DATA_QUERIES,
CREATE_DICTIONARY_QUERIES,
build_query,
)

Expand All @@ -25,12 +26,15 @@ def create_clickhouse_tables(num_tables: int):
if num_tables == len(CREATE_TABLE_QUERIES):
return

queries = list(map(build_query, CREATE_TABLE_QUERIES))
run_clickhouse_statement_in_parallel(queries)
table_queries = list(map(build_query, CREATE_TABLE_QUERIES))
run_clickhouse_statement_in_parallel(table_queries)

data_queries = list(map(build_query, CREATE_DATA_QUERIES))
run_clickhouse_statement_in_parallel(data_queries)

dictionary_queries = list(map(build_query, CREATE_DICTIONARY_QUERIES))
run_clickhouse_statement_in_parallel(dictionary_queries)


def reset_clickhouse_tables():
# Truncate clickhouse tables to default before running test
Expand Down Expand Up @@ -76,6 +80,12 @@ def reset_clickhouse_tables():

run_clickhouse_statement_in_parallel(TABLES_TO_CREATE_DROP)

from posthog.clickhouse.schema import (
CREATE_DATA_QUERIES,
)

run_clickhouse_statement_in_parallel(list(CREATE_DATA_QUERIES))


@pytest.fixture(scope="package")
def django_db_setup(django_db_setup, django_db_keepdb):
Expand Down

0 comments on commit 336acaa

Please sign in to comment.