Socket
Book a DemoInstallSign in
Socket

@aragornhq/ch-migration

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aragornhq/ch-migration

Production-grade ClickHouse migration CLI with rollback, test coverage, and GitHub Actions support

1.1.2
latest
Source
npmnpm
Version published
Weekly downloads
134
-49.43%
Maintainers
1
Weekly downloads
 
Created
Source

@aragornhq/ch-migration

⚔️ Production-grade CLI for managing ClickHouse schema migrations with raw SQL, rollback, integrity tracking, strict mode, and GitHub automation.

🚀 Features

📦 Installation

npm install --save-dev @aragornhq/ch-migration

🔧 Setup

  • Set the ClickHouse connection using environment variables (prefixed with CH_):
CH_HOST=localhost
CH_PORT=8123
CH_DB=default
CH_USER=default
CH_PASSWORD=
# set to "true" when using HTTPS
CH_USE_TLS=false
# optional: set cluster name for `${CH_CLUSTER}`
CH_CLUSTER=
  • Specify where your migration files live via a ch-migration.json file:
{
  "path": "db/migrations"
}

Create the folder if it does not already exist.

🛠️ Usage

Run the CLI with npx or via an npm script. The executable name is ch-migrate:

npx ch-migrate <command> [options]

Commands

  • migration:create <name> --path=<folder> – create a timestamped migration file. The --path option is optional when the path is defined in ch-migration.json.
  • migration:up --path=<folder> [--dry-run] – apply all pending migrations. Use --dry-run to preview without applying.
  • migration:down --file=<filename.sql> --path=<folder> – roll back a single migration.
  • dump --out=<file> – export CREATE statements for all tables in the current database. Each statement includes IF NOT EXISTS and no DROP statements so rerunning is safe.

Each file should contain your SQL up statement followed by -- ROLLBACK BELOW -- and the down statement. Only one SQL statement per section is enforced.

-- 20250101_create_table.sql
CREATE TABLE example (id UInt8) ENGINE = MergeTree;

-- ROLLBACK BELOW --
DROP TABLE example;

Applied migrations are recorded in a migrations table together with a SHA‑256 hash. If a hash changes, the run fails to prevent drift.

Keywords

clickhouse

FAQs

Package last updated on 26 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.