---
name: clickhouse-upgrade-migration
description: |-
  Use when upgrading ClickHouse server versions or the @clickhouse/client SDK,
  handling breaking changes between versions, or migrating from older client
  libraries — covers version checks, changelog review, staged upgrade, post-upgrade
  validation, and rollback.
  Trigger with phrases like "upgrade clickhouse", "clickhouse version upgrade",
  "update clickhouse client", "clickhouse breaking changes", "new clickhouse version".
allowed-tools: Read, Edit, Bash(npm:*), Bash(git:*)
version: 1.7.0
license: MIT
author: Jeremy Longshore <jeremy@intentsolutions.io>
tags:
  - saas
  - database
  - analytics
  - clickhouse
  - olap
compatibility: Designed for Claude Code
title: clickhouse-upgrade-migration
canonical_url: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/clickhouse-upgrade-migration
last_updated: 2026-10-07T06:06:28.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/examples.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/clickhouse-upgrade-migration/references/examples.md), [references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/clickhouse-upgrade-migration/references/implementation.md).
>
> If the user asked to install this Skill, run `npx skilld install jeremylongshore/tons-of-skills-marketplace/clickhouse-upgrade-migration`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/clickhouse-upgrade-migration`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jeremylongshore/tons-of-skills-marketplace/clickhouse-upgrade-migration) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/clickhouse-upgrade-migration`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/clickhouse-upgrade-migration --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/clickhouse-upgrade-migration --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# ClickHouse Upgrade & Migration

## Overview

Safely upgrade ClickHouse server and the `@clickhouse/client` Node.js SDK, with
rollback procedures and breaking-change detection. The workflow is check versions
→ review changelogs → upgrade the client → upgrade the server → validate →
rollback if needed. Full command sequences live in
[references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/clickhouse-upgrade-migration/references/implementation.md); the runnable
migration, validation, and rollback code lives in
[references/examples.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/clickhouse-upgrade-migration/references/examples.md).

## Prerequisites

- Current ClickHouse version known (`SELECT version()`)
- Git for version control (client changes land on an `upgrade/` branch)
- Test suite for integration validation (`npm test`)
- Staging environment for pre-production testing
- `CLICKHOUSE_HOST` set (and credentials — see Authentication)

## Authentication

The client and validation scripts read the server URL from the
`CLICKHOUSE_HOST` environment variable (e.g. `http://localhost:8123` locally, or
your ClickHouse Cloud endpoint). Keep credentials in the environment, never
hardcoded: pass `username` / `password` to `createClient` from
`process.env.CLICKHOUSE_USER` / `CLICKHOUSE_PASSWORD`, and for raw `curl` send
them via the `X-ClickHouse-User` / `X-ClickHouse-Key` headers. ClickHouse Cloud
endpoints require TLS (`https://`) and a password; self-hosted default installs
often run open on `8123` (the HTTP port) in dev only.

## Instructions

Work the steps in order — the client upgrade and the server upgrade are separate,
independently reversible changes. Read
[references/implementation.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/clickhouse-upgrade-migration/references/implementation.md) for the full command
sequence of each step.

### Step 1: Check Current Versions

Capture the server version, the installed client version, and the latest
published client before changing anything — this is your rollback target.

```bash
curl 'http://localhost:8123/?query=SELECT+version()'   # server
npm list @clickhouse/client                            # installed client
npm view @clickhouse/client version                    # latest available
```

### Step 2: Review Changelog

Read the client and server changelogs and note breaking changes: `createClient`
option renames, default setting changes (compression, timeouts), query
result-format behavior, removed SQL functions, and renamed MergeTree settings.
Full checklist and links: implementation.md Step 2.

### Step 3: Upgrade the Node.js Client

Isolate the client bump on a branch so it is reversible independent of the server.

```bash
git checkout -b upgrade/clickhouse-client
npm install @clickhouse/client@latest
npm test
```

Then apply the code-migration patterns (the `host` → `url` option rename and the
`rs.json()` result-shape change) — full before/after in
[references/examples.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/clickhouse-upgrade-migration/references/examples.md) under "Common migration patterns".
Edit the client-initialization and result-handling code to match.

### Step 4: Upgrade ClickHouse Server

ClickHouse Cloud upgrades automatically — just read the console release notes.
Self-hosted follows a fixed sequence: **backup → check changed settings → stop →
`apt-get install` → start → verify version → scan schema**. Full command block:
implementation.md Step 4.

### Step 5: Validate After Upgrade

Run the post-upgrade validation script — ping, version, schema, insert, and query
checks, each reporting PASS/FAIL. Full script:
[references/examples.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/clickhouse-upgrade-migration/references/examples.md) under "Post-upgrade validation script".

### Step 6: Rollback Procedure

If validation fails, roll back the client (`npm install` the previous version
with `--save-exact`), the server package, and — if data is affected — `RESTORE` from the
pre-upgrade backup. Full commands:
[references/examples.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/clickhouse-upgrade-migration/references/examples.md) under "Rollback commands".

## Version Compatibility Matrix

| Client Version | Min Server Version | Node.js | Key Changes |
|---------------|-------------------|---------|-------------|
| 1.x | 22.6+ | 18+ | Stable API, `url` option |
| 0.3.x | 22.6+ | 16+ | `host` option, different JSON result shape |
| 0.2.x | 21.8+ | 14+ | Initial release |

## Output

- Current and target versions recorded (server + client) as the rollback baseline
- Client upgraded on an isolated `upgrade/` branch with `npm test` green
- Code migrated for known breaking changes (`host` → `url`, `rs.json()` shape)
- Server upgraded via the backup → stop → install → verify sequence
- Post-upgrade validation run: ping, version, schema, insert, and query all PASS
- Documented rollback path for both client and server if any check fails

## Error Handling

| Issue | Cause | Solution |
|-------|-------|----------|
| `Unknown setting` | New default in config | Remove deprecated setting |
| `Cannot parse datetime` | Format change | Update date format strings |
| `Method not found` | Client API changed | Check migration guide |
| `Checksum mismatch` | Corrupted upgrade | Rollback and re-download |

## Examples

Two ready-to-run starting points live in
[references/examples.md](https://skilld.dev/api/skills-raw/jeremylongshore/tons-of-skills-marketplace/clickhouse-upgrade-migration/references/examples.md):

- **Common migration patterns** — before/after for the `createClient` option
  rename and the `rs.json()` result-shape change between v0.x and v1.x.
- **Post-upgrade validation script** — a self-contained check runner that
  exercises ping → version → schema → insert → query.

```typescript
// Validation entry point — full runner in references/examples.md
const client = createClient({ url: process.env.CLICKHOUSE_HOST! });
await client.ping();                                          // 1. reachable
await client.query({ query: 'SELECT version()', format: 'JSONEachRow' }); // 2. new version live
// 3. schema, insert, and query checks follow in the full script
```

## Resources

- [Client Releases](https://github.com/ClickHouse/clickhouse-js/releases)
- [Server Changelog](https://github.com/ClickHouse/ClickHouse/blob/master/CHANGELOG.md)
- [ClickHouse Cloud Upgrades](https://clickhouse.com/docs/en/manage/updates)

## Next Steps

For CI/CD integration of the upgraded client, see `clickhouse-ci-integration`.
For pre-production release gating, see `clickhouse-prod-checklist`.
