Registry / database / migrate-clickhouse

migrate-clickhouse

JSON →
library1.1.1jsnpmunverified

A database migration tool for Clickhouse in Node.js, version 1.1.1. It provides CLI commands (init, create, up, down, status) and a programmatic API for managing schema migrations in Clickhouse databases. Unlike generic migration tools, it is tailored for Clickhouse-specific features like columnar storage and distributed queries. The package has low weekly downloads and appears to be maintained by a single developer. Release cadence is irregular.

npm install migrate-clickhouse
INSTALL
IMPORT
SIG · MIGRATE-CLICKHOUSE
M
migrate-clickhouse
databasejavascriptv1.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import migrate from 'migrate-clickhouse'
const migrate = require('migrate-clickhouse')
ESM/CJS hybrid; the default export is an object with methods like up, down, status.
up
import { up } from 'migrate-clickhouse'
Named export for programmatic migration; requires config.
init
import { init } from 'migrate-clickhouse'
Named export for initializing a migration project programmatically.

Programmatically run pending migrations using the up function with a configuration object.

import { up } from 'migrate-clickhouse'; const config = { clickhouse: { url: process.env.CLICKHOUSE_URL || 'http://localhost', port: parseInt(process.env.CLICKHOUSE_PORT || '8123'), database: process.env.CLICKHOUSE_DB || 'default', basicAuth: { username: process.env.CLICKHOUSE_USER || 'root', password: process.env.CLICKHOUSE_PASS || 'root' } }, migrationsDir: 'migrations', migrationsTableName: 'changelog' }; async function runMigrations() { try { const result = await up(config); console.log('Migrations ran:', result); } catch (err) { console.error('Migration failed:', err); } } runMigrations();
Debug
Known issues
gotchaConfiguration file uses Node.js module.exports syntax, not ESM. If using ESM project, you need to dynamically import or convert config.
fix
Use dynamic import: const config = await import('./migrate-clickhouse-config.js'); or convert config to ESM.
affects: >=1.0.0
gotchaThe package requires the clickhouse npm client (^2.6.0) as a peer dependency. Missing it will cause runtime errors.
fix
Install the peer dependency: npm install clickhouse@^2.6.0
affects: >=1.0.0
deprecatedThe clickhouse npm client (used as peer dep) is outdated; consider using @clickhouse/client for new projects.
fix
Switch to @clickhouse/client and adapt config accordingly (not supported by migrate-clickhouse directly).
affects: >=1.0.0
gotchaMigrations are JavaScript files by default; ensure they export async functions for up/down. Wrong exports lead to silent failures.
fix
Export a function: module.exports = { up, down }; where up and down are async functions receiving a clickhouse connection.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'clickhouse'
Missing peer dependency clickhouse.
fix
npm install clickhouse@^2.6.0
migrate-clickhouse: command not found
Global installation missing or not in PATH.
fix
Install globally: npm install -g migrate-clickhouse
TypeError: up is not a function
Incorrect import (default vs named).
fix
Use import { up } from 'migrate-clickhouse' or import migrate from 'migrate-clickhouse' and use migrate.up.
Upgrade
Version history
1.1.1latest on npm
Audit
Dependencies
clickhouserequiredClickhouse client for database connections
Agent activity
4 hits · last 30 days
node
4
Resources
migrate-clickhouse — npm install migrate-clickhouse · libregistry