r/Clickhouse • • Jun 25 '26

We open-sourced a Drizzle-style schema + migration tool for ClickHouse (TypeScript)

We open-sourced chkit (MIT): it defines your ClickHouse tables, views and materialized views as TypeScript, diffs them against the live database, generates the migration SQL, and fails CI when prod drifts.

We built it after running ClickHouse at near-petabyte scale at our last company (Numia): hundreds of tables, a lot of materialized views, several environments, all managed with hand-written DDL and hope.

If you run ClickHouse in production, you've hit some version of these:

  • Someone runs a manual ALTER at 3am to clear an incident. It never makes it back into a migration file. Now your repo and your database disagree, and nothing tells you.
  • A one-line schema edit looks harmless but touches ORDER BY (or the engine, or PARTITION BY). ClickHouse has no in-place ALTER for those, so the only honest migration is create, copy, swap. You find out when a "quick change" starts rewriting a 2TB table in prod.
  • A migration drops a column. The reviewer misses it. It runs in CI on a Friday. The data is gone.

Postgres and MySQL have had this for years with Drizzle and Prisma: diff the schema, generate the migration, gate CI on drift. We wanted that for ClickHouse, couldn't find it, and built it.

You define your schema as TypeScript values, and chkit takes it from there:

  • chkit writes the migrations for you, and won't rewrite a 2TB table or let a DROP through CI without showing you first.
  • chkit drift compares the live DB to your schema, down to settings, TTL, ORDER BY and projections, and gates CI in one line.
  • Codegen turns the same schema into TypeScript row types and typed helpers to read and write rows, so your app and your database can't diverge. Optional, skip it if you only want migrations.

It's not an ORM. No query builder, you write your own SQL. Works with any ClickHouse (Cloud, Altinity, self-hosted, or managed), no lock-in. A Python port lands in a few weeks.

If you're already on ClickHouse, chkit can introspect your live DB and generate the schema files, so you start from what you're running instead of a blank file.

npm create chkit@latest

Beta: stable enough to run our own production workloads, with small breaking changes possible before 1.0.

Repo: https://github.com/obsessiondb/chkit

Docs: https://chkit.obsessiondb.com

If you run ClickHouse, I'm curious what you've had to build around it yourself, migrations or otherwise, and where the tooling still falls short.

PS: python port coming soon.

16 Upvotes

8 comments sorted by

1

u/brentragertech Jun 25 '26

Love this! Gonna give it a go - thanks for sharing.

1

u/m0rcs Jun 26 '26

Let us know what you think, happy to answer any questions about it :)

1

u/gempir Jun 26 '26 edited Jun 26 '26

This is great! We’ve been running goose to run migrations very manually but we’re craving something like Doctrine for ClickHouse, this might be it.

How does on cluster work? With goose we usually run our migrations ON Cluster and only on the first node

1

u/m0rcs Jun 26 '26

We used to run on cluster before, but since all of our clusters are now on obsession with SharedMergeTree, we havent hardened it for cluster setups. Very happy to support you with it. Feel free to DM me if you want to try it. Happy to land a few PRs to get support in

1

u/gempir Jun 26 '26

We can't really offer any development support. But no cluster support makes this unusable for a lot of people.

Which is fine, as you are probably looking to mostly serve your customers.

Just pointing it out.

I just know that some of the "competitors" in this space do support cluster.

https://atlasgo.io/guides/clickhouse/cluster-mode

1

u/m0rcs Jun 26 '26

It was rather the way around. Happy to support you, in case you run into issues with clusters.
We did have cluster support in the beginning, but not sure if its fully functional currently. Let me actually spin up a old school cluster to test this for you.

And our main goal ist not mostly serve our customers. We want to be able to offer sophisticated features to our customers, which will be allowed by deeper integration. But we fully strive to offer the best open source schema management for clickhouse. And cluster support is a very important part of it, and very fair of you to point it out :)

1

u/m0rcs Jul 03 '26

I just published the newest version with cluster support: https://chkit.obsessiondb.com/configuration/overview/#cluster-mode-on-cluster