clickhouse-migrations
БесплатноБез исполняемых скриптовНе проверенClickHouse migration patterns and rules. Use when creating or modifying ClickHouse migrations.
от PostHog★ 41 278 звёзд на GitHubОб этом скилле
ClickHouse Migrations
Read posthog/clickhouse/migrations/AGENTS.md for comprehensive patterns, cluster setup, examples, and ingestion layer details.
Quick reference
Migration structure
operations = [
run_sql_with_exceptions(
SQL_FUNCTION(),
node_roles=[...],
sharded=False, # True for sharded tables
is_alter_on_replicated_table=False # True for ALTER on replicated tables
),
]
Node roles (choose by the cluster that owns the object)
Only the members of NodeRole in posthog/clickhouse/client/connection.py are valid: ALL, DATA,
INGESTION_EVENTS, INGESTION_SMALL, INGESTION_MEDIUM, INGESTION_METRICS, ENDPOINTS, LOGS, METRICS, INGESTION_APM,
AI_EVENTS, AUX, BATCH_EXPORTS, 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]: objects that belong on the main cluster — sharded tables, theDistributedread tables in front of sharded or satellite tables, views, dictionaries. A non-sharded replicated table onDATAkeeps a full copy on every main-cluster node, so it is the wrong home for a product rollup or pre-aggregate (see below).[NodeRole.INGESTION_SMALL],[NodeRole.INGESTION_MEDIUM],[NodeRole.INGESTION_EVENTS]: writable tables, Kafka tables, materialized views on the ingestion layer.INGESTION_EVENTSis for consumers of all ofclickhouse_events_json. For other topics, check where comparable consumers run in each environment, and useINGESTION_SMALLorINGESTION_MEDIUMto match. UseINGESTION_SMALLwhen you can't tell.[NodeRole.INGESTION_APM]: theingestion-apmnodes, the metrics ingestion layer. Kafka tables,Nullinput tables, materialized views and writableDistributedtables that write into storage onLOGS. Stateless like the other ingestion nodes, so storage tables never go here.[NodeRole.METRICS],[NodeRole.INGESTION_METRICS]: themetricscluster and theingestion-metricsnodes that write to it. In cloud the metrics4 tables run only on these (0376 and 0379 removed them fromINGESTION_APMandLOGS). The local stacks still run them onINGESTION_APMandLOGS, so a metrics4 change targets both pairs.[NodeRole.OPS],[NodeRole.LOGS],[NodeRole.AUX],[NodeRole.AI_EVENTS],[NodeRole.SESSIONS],[NodeRole.BATCH_EXPORTS]: objects that live on a satellite cluster. A table for one of those onDATAlands on the wrong nodes and leaves the intended cluster without it, so check where the object is read and written before defaulting toDATA. Dev runs the same satellite clusters as US/EU prod — never branch onCLOUD_DEPLOYMENTto give dev a different layout.[NodeRole.ALL]: rarely used
Pre-aggregates and rollups are stored on a satellite and read through a Distributed table on DATA
(and on the storage satellite, for ad-hoc reads there), unless the app already connects to that satellite
directly. A rollup of a satellite's own data stays on that
satellite; general product pre-aggregates go to AUX. Confirm the satellite with the live check below,
and find a current example's HCL layers with hclexp locate.
Check the live clusters before choosing a role
Older migrations, the HCL local layers and shared helpers can trail what runs in dev and production. Confirm placement against the live clusters before writing the migration:
- Use the ClickHouse MCP to check each of dev, prod-us and prod-eu: where comparable tables live,
which satellite tables the main cluster reads through
Distributedtables, and that the new table names are unused. See the Housekeeper MCP runbook for setup and usage. - When precedents disagree, follow the newest migration for that table family and confirm it matches what runs in all three environments. A layout that only some environments still run is mid-migration, not a pattern to copy.
- State in the PR description which cluster each new object lands on, and name the reference migration or live check behind the choice.
Table engines quick reference
MergeTree engines:
AggregatingMergeTree(table, replication_scheme=ReplicationScheme.SHARDED)for sharded tablesReplacingMergeTree(table, replication_scheme=ReplicationScheme.REPLICATED)for non-sharded- Other variants:
CollapsingMergeTree,ReplacingMergeTreeDeleted
Distributed engine:
- Sharded:
Distributed(data_table="sharded_events", sharding_key="sipHash64(person_id)") - Non-sharded:
Distributed(data_table="my_table", cluster=settings.CLICKHOUSE_SINGLE_SHARD_CLUSTER)
Kafka engine — kafka_engine() returns the ENGINE clause only, so every table appends its own
SETTINGS. Start from this baseline:
SETTINGS k
Установить clickhouse-migrations в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл clickhouse-migrations?
ClickHouse migration patterns and rules. Use when creating or modifying ClickHouse migrations.
Как установить скилл clickhouse-migrations?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл clickhouse-migrations запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic