posthog/management/commands/setup_test_environment.py
from posthog.test.base import run_clickhouse_statement_in_parallel
    queries = list(map(build_query, queries))
    run_clickhouse_statement_in_parallel(queries)
def disable_migrations() -> None:
    """
    Disables django migrations when creating test database. Model definitions are used instead.
    Speeds up setup significantly.
    """
    from django.conf import settings
    from django.core.management.commands import migrate
    class DisableMigrations:
        def __contains__(self, item: str) -> bool:
            return True
        def __getitem__(self, item: str) -> None:
            return None
    class MigrateSilentCommand(migrate.Command):
        def handle(self, *args, **kwargs):
            from django.db import connection
            
            with connection.cursor() as cursor:
                cursor.execute("CREATE EXTENSION pg_trgm")
            return super().handle(*args, **kwargs)
    settings.MIGRATION_MODULES = DisableMigrations()
    migrate.Command = MigrateSilentCommand