Skip to content

chore(clickhouse): remove retired python migrations and hcl tooling - #111082

Draft
rorylshanks wants to merge 2 commits into
codex/clickhouse-schema-cutoverfrom
codex/clickhouse-schema-cleanup
Draft

rorylshanks wants to merge 2 commits into
codex/clickhouse-schema-cutoverfrom
codex/clickhouse-schema-cleanup

Conversation

@rorylshanks

@rorylshanks rorylshanks commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Maintainers can remove retired migration integrations after the new execution path is stable.

Changes

Deletes Python ClickHouse migrations, deployment-only DDL helpers, old HCL tooling and unused dependencies. Preserves runtime queries and SQL helpers required by isolated fixtures.

Rollout gate: Merge after cutover has been observed and infra ownership is complete. Pair final deletion with infra cleanup https://github.com/PostHog/posthog-cloud-infra/pull/10908. No schema DDL belongs in this layer. Merge bottom-first; do not land the whole stack together.

Before:

flowchart LR
  A["Declarative setup and dormant integrations"] --> B["Repository"]
  classDef phBlue fill:#1d4aff,stroke:#1d4aff,color:#fff;
  classDef phGray fill:#e5e7eb,stroke:#c7ccd1,color:#000;
  class A phBlue;
  class B phGray;
Loading

After:

flowchart LR
  A["Declarative setup"] --> B["Repository"]
  classDef phBlue fill:#1d4aff,stroke:#1d4aff,color:#fff;
  classDef phGray fill:#e5e7eb,stroke:#c7ccd1,color:#000;
  class A phBlue;
  class B phGray;
Loading

How did you test this code?

Local catalogue validation and table-family checks passed, including the empty second plan. posthog/clickhouse/test/test_managed_schema.py --reuse-db passed against local services. Python lint/format, lockfile and workflow checks passed. GitHub script tests passed with GNU sed, matching Linux CI; the pinned schema formatter passed. Live cloud rollout, the complete backend suite and both events-schema variants remain CI/review gates.

Test rationale: The imported managed-schema regression checks reconstruction after fixture restore. Existing table-family checks validate the catalogue and require an empty second plan; no split-only tests were added.

Release status

  • No feature flag controls this change
  • This change is behind a feature flag and is not available to users
  • This change makes a previously flagged feature available to everyone

Automatic notifications

  • Publish to changelog?

Docs update

Updated the existing schema README and applicable schema-change guidance to describe this rollout stage.

🤖 Agent context

Autonomy: Human-driven (agent-assisted). Agent: Codex, GPT-6.

Staged replacement for #109937, which remains available for comparison. Source changes were split using Git, GitHub CLI and gh stack; current master changes were retained. Skills: /stacking-prs, /writing-pr-descriptions, /running-ci-preflight, /authoring-ci-workflows, /clickhouse-migrations, /writing-tests, /writing-code-comments and /reviewing-with-coderabbit. Local CodeRabbit review was skipped at the directing user's request because the CLI was missing. No customer material was used. Human review and CI patch coverage are pending on this draft.

@rorylshanks rorylshanks added the test-new-events-schema Run the backend CI matrices twice: legacy events schema and native JSON events schema label Oct 2, 2026
@rorylshanks rorylshanks self-assigned this Oct 2, 2026
@rorylshanks
rorylshanks added this pull request to stack #111084 October 2, 2026 18:59
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

🚨 Trunk lane — universal lane

This PR is assigned to the universal lane. It cannot merge in parallel with other PRs, so it can take longer to merge. Ask dev-ex if you think this is wrong.

✅ Duplication (Python) — clean

New Python code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

✅ Duplication (TypeScript) — clean

New TypeScript code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

@rorylshanks
rorylshanks force-pushed the codex/clickhouse-schema-cleanup branch from 1293e13 to 4ae7b26 Compare October 2, 2026 19:01
@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Retrigger

[High risk] Removes Python migration tooling and HCL schema system.

The PR appears safe to merge, though the lost projection coverage and incorrect documentation references should be addressed.

Reviews (1) · Last reviewed commit: 1293e13

@@ -79,7 +85,7 @@ session_id_v7 UInt128,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Schema guide cites nonexistent files

The updated guide points readers to catalog/events/columns.tf here and catalog/events/families.tf in the materialized-columns section, but neither file exists. The cited column and indexes are in catalog/events/main.tf. Point both references there so developers can find the examples.

Prompt To Fix With AI
This is a comment left during a code review.
Path: docs/published/handbook/engineering/databases/clickhouse-queries-new-products.md
Line: 85

Comment:
**Schema guide cites nonexistent files**

The updated guide points readers to `catalog/events/columns.tf` here and `catalog/events/families.tf` in the materialized-columns section, but neither file exists. The cited column and indexes are in `catalog/events/main.tf`. Point both references there so developers can find the examples.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@greptile-apps

greptile-apps Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff

These findings could not be posted inline.

  • P2 Billing projection coverage removed posthog/models/usage_report_events_preagg/test/test_usage_report_events_preagg_mv.py:150 ▶

    This deletion removes the test that checks billable-event counts and deduplication when an event is replayed. The declared materialized view still performs that aggregation, so a later change to its grouping or uniqExactState expression could change billing counts without a test catching it. Recreate these cases against the declared schema.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

  • P2 Log retention coverage removed posthog/clickhouse/test/test_schema.py:146 ▶

    This deletion removes checks for late, future, subsecond, negative, and mixed-retention logs. Those cases determine whether volume buckets last long enough to represent the underlying logs; a later schema or projection change could make buckets expire early without being caught. Preserve these cases in a test of the declared projection.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@rorylshanks
rorylshanks force-pushed the codex/clickhouse-schema-cleanup branch from 4ae7b26 to 490911f Compare October 2, 2026 19:17
@trunk-io

trunk-io Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge

View Full Report ↗︎ ⋅ Docs

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test-new-events-schema Run the backend CI matrices twice: legacy events schema and native JSON events schema

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant