Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(skills): drop the nonexistent NodeRole.COORDINATOR from the CH migration skill (#81018)

Eli Reisman06175c680ded
diff --git a/.agents/skills/clickhouse-migrations/SKILL.md b/.agents/skills/clickhouse-migrations/SKILL.md
index 2baa21d7b1e0..067dd3a85da7 100644
--- a/.agents/skills/clickhouse-migrations/SKILL.md
+++ b/.agents/skills/clickhouse-migrations/SKILL.md
@@ -22,11 +22,23 @@ operations = [
]
```
-### Node roles (choose based on table type)
+### Node roles (choose by the cluster that owns the object)
-- `[NodeRole.DATA]`: Sharded tables (data nodes only)
-- `[NodeRole.DATA, NodeRole.COORDINATOR]`: Non-sharded data tables, distributed read tables, replicated tables, views, dictionaries
-- `[NodeRole.INGESTION_SMALL]`: Writable tables, Kafka tables, materialized views on ingestion layer
+Only the members of `NodeRole` in `posthog/clickhouse/client/connection.py` are valid: `ALL`, `DATA`,
+`INGESTION_EVENTS`, `INGESTION_SMALL`, `INGESTION_MEDIUM`, `ENDPOINTS`, `LOGS`, `AI_EVENTS`, `AUX`,
+`OPS`, `SESSIONS`. A name that is not in that enum fails at import, which aborts migration discovery
+and takes every job that runs migrations down with it.
+
+Pick the role by **which cluster owns the object**, not by its type alone:
+
+- `[NodeRole.DATA]`: anything on the main cluster — sharded tables, non-sharded replicated tables,
+ distributed read tables, views, dictionaries. The default, and right for most migrations.
+- `[NodeRole.INGESTION_SMALL]`: writable tables, Kafka tables, materialized views on the ingestion layer
+- `[NodeRole.OPS]`, `[NodeRole.LOGS]`, `[NodeRole.AUX]`, `[NodeRole.AI_EVENTS]`, `[NodeRole.SESSIONS]`:
+ objects that live on a satellite cluster. A table for one of those on `DATA` lands on the wrong
+ nodes and leaves the intended cluster without it, so check where the object is read and written
+ before defaulting to `DATA`.
+- `[NodeRole.ALL]`: rarely used
### Table engines quick reference
@@ -92,6 +104,26 @@ The only exception is tables whose definition intentionally differs per environm
**Dictionary credentials:** when a dictionary uses a `SOURCE(CLICKHOUSE(...))`, resolve the source user/password via `get_clickhouse_creds(ClickHouseUser.DICT_READER)` and interpolate them into the `USER`/`PASSWORD` clause — do not hardcode `default`/`CLICKHOUSE_USER` or omit credentials. This keeps dictionary auth on the dedicated low-privilege `dict_reader` user, decoupled from `default`; it falls back to `default` creds when the env vars are unset. See `posthog/models/exchange_rate/sql.py` for the pattern.
+### Declarative schema (HCL) must agree
+
+Some roles are also declared in `posthog/clickhouse/hcl/`, and the multinode migration smoke re-introspects
+the migrated cluster and fails on any drift between the live schema and the committed golden. A table added
+by a migration on a managed role therefore needs the HCL updated in the same PR, or CI fails at
+`check_live_hcl` with a `DRIFT:` block naming your new objects.
+
+The `data` role is managed for the `local-multi` composition, so a new table on `NodeRole.DATA` counts.
+After writing the migration:
+
+```sh
+HCL=posthog/clickhouse/hcl
+# add the table to the layer that composes it, e.g. $HCL/roles/data/local/tables.hcl
+bash $HCL/gen-golden.sh && bash $HCL/gen-sql.sh # refresh generated artifacts
+bash $HCL/check.sh # must exit 0
+```
+
+Read `posthog/clickhouse/hcl/README.md` before editing a layer — it covers which layer to pick, abstract
+column lists, and the codegen path that writes the migration for you.
+
### Testing
Delete entry from `infi_clickhouse_orm_migrations` table to re-run a migration.