Getting Started with Schema Management
chkit manages ClickHouse schemas and migrations in TypeScript and Python: define tables in code, generate SQL, review the migration, and apply it to the database.
Start with the first-schema tutorial to learn the workflow from an empty folder, or add chkit to an existing application.
Let an agent set it up
Section titled “Let an agent set it up”Paste this prompt into your coding agent to install chkit, configure the project, and prepare the first migration. The prompt links to the agent instructions.
Set up chkit (ClickHouse schema management) in this repo. First fetch https://chkit.obsessiondb.com/ai-agents.md and follow the instructions there: install the agent skill, scaffold the config, recommend any plugins this project needs, and walk me through the first migration. Don't apply anything to the database without confirming with me first. Set up manually
Section titled “Set up manually”Prefer a complete TypeScript starter? Start with the schema example to scaffold two tables and their migration.
Already have tables in ClickHouse? Use schema introspection to import their definitions before planning changes. For typed application code, add row model generation after defining the schema.
Prerequisites
Section titled “Prerequisites”Choose the runtime for the project’s language and a database target:
- Node.js 20+ or Bun 1.3.5+ for TypeScript, or Python 3.11+ for Python
- A ClickHouse 24.x or newer endpoint (see compatibility), or a free ObsessionDB dev instance claimed during setup. For a direct connection, set
CLICKHOUSE_URLand any requiredCLICKHOUSE_USER/CLICKHOUSE_PASSWORDvalues.
Where to next
Section titled “Where to next”Once either path is working:
- The migration workflow: how generate, snapshot, and migrate fit together, and what to commit
- CLI reference: every command, flag, and expected output
- Configuration: wire up
clickhouse.config.ts - Schema DSL: define tables, views, materialized views, and dictionaries
- Troubleshooting: fixes for common errors if a command fails