Skip to content

Schema Plugins

Extend the schema workflow with row model generation, imports from a live database, and SQL backfills. Install TypeScript plugins as npm packages; plugins for the beta Python implementation ship inside chkit-py. The backfill plugin is in beta. Register plugins in the schema configuration:

import { defineConfig } from '@chkit/core'
import { codegen } from '@chkit/plugin-codegen'
import { pull } from '@chkit/plugin-pull'
export default defineConfig({
schema: './src/db/schema/**/*.ts',
outDir: './chkit',
plugins: [
codegen({ outFile: './src/generated/chkit-types.ts' }),
pull({ outFile: './src/db/schema/pulled.ts' }),
],
// ...
})

Plugin authors use lifecycle hooks to transform schema definitions before a diff, register CLI commands, run setup (onInit) or teardown (onComplete), and transform SQL before migration (onBeforeApply). The CLI: chkit plugin command lists plugins active in your config.

Follow the plugin reference to configure a published plugin. Use the lifecycle hooks when writing a plugin.

You can author your own plugins; the existing official plugins are the reference. See Contributing for the entry point.

For @chkit/plugin-obsessiondb (Python: chkit_plugin_obsessiondb), see the ObsessionDB section.

  • @chkit/plugin-codegen: TypeScript row types and optional Zod schemas (Python: Pydantic models), generated from your schema files.
  • @chkit/plugin-pull: introspect a live ClickHouse database into local schema files. Useful for adopting chkit on an existing database. Built into the Python CLI as chkit pull.
  • @chkit/plugin-tinybird: translate a Tinybird project into chkit tables, materialized views, refreshable materialized views and typed queries, reporting what does not translate.
  • @chkit/plugin-backfill (beta): partition/sort-key data backfill with checkpoints, for materialized views and historical data loads.