Skip to main content

ClickMigrate

A modern, lightweight, and reliable database migration framework for ClickHouse, inspired by Alembic.

ClickMigrate provides a clean CLI and Python API for managing ClickHouse schema migrations without unnecessary complexity.

About

ClickMigrate is an open-source project developed and maintained by QueueForge. It is designed to provide a modern, simple, and reliable migration framework for ClickHouse databases. Learn more about QueueForge at https://queueforge.dev.


Features

  • SQL-based Migrations – Write your migrations in plain .sql files.
  • Automatic Ordering – Lexicographical sorting ensures migrations run in the correct sequence.
  • State Management – Automatically creates and manages a migration history table in ClickHouse.
  • Checksum Validation – Validates SHA-256 checksums to detect modified applied migrations.
  • Flexible Configuration – Supports pyproject.toml, JSON, YAML, or environment variables.
  • Project Initialization – clickmigrate init automatically creates a pyproject.toml configuration file with sensible defaults.
  • Dry-Run Mode – Preview which migrations will be applied without altering the database.
  • Python API & CLI – Use ClickMigrate from your terminal or programmatically in Python.
  • Version Command – Display the installed ClickMigrate version with clickmigrate version.

Installation

ClickMigrate requires Python 3.11+.

Install it using pip:

pip install ClickMigrate

Quick Start (CLI)

ClickMigrate provides an Alembic-like CLI for managing your migration workflow.

1. Initialize the Environment

Create the migration directory (default: migrations/) and generate a pyproject.toml configuration file with default settings if one does not already exist.

clickmigrate init

2. Create a Revision

Generate a new sequential SQL migration file.

clickmigrate revision -m "create users table"

Example output:

migrations/
└── 001_create_users_table.sql

Edit the generated file and add your ClickHouse SQL statements.


3. Check Status

View applied and pending migrations, including the version and name of each pending migration.

clickmigrate status

4. Apply Migrations

Run all pending migrations. Progress and execution time are displayed for each migration.

clickmigrate migrate

Preview the execution without applying changes:

clickmigrate migrate --dry-run

5. Validate Migration Integrity

Verify that previously applied migration files have not been modified.

clickmigrate validate

6. Show Version

Display the installed ClickMigrate version.

clickmigrate version

Configuration

ClickMigrate automatically searches for configuration files in your project root.

Supported formats (in priority order):

  1. pyproject.toml (recommended)
  2. clickmigrate.json
  3. clickmigrate.yaml
  4. Environment variables
[tool.clickmigrate]
host = "localhost"
port = 8123
database = "default"
username = "default"
password = "your_secure_password"

migration_directory = "migrations"
migration_table = "clickmigrate_history"

Option B: clickmigrate.json

{
  "host": "localhost",
  "port": 8123,
  "database": "default",
  "username": "default",
  "password": "your_secure_password",
  "migration_directory": "migrations",
  "migration_table": "clickmigrate_history"
}

Option C: clickmigrate.yaml

host: localhost
port: 8123
database: default
username: default
password: your_secure_password

migration_directory: migrations
migration_table: clickmigrate_history

Option D: Environment Variables

CLICKMIGRATE_HOST=localhost
CLICKMIGRATE_PORT=8123
CLICKMIGRATE_DATABASE=default
CLICKMIGRATE_USERNAME=default
CLICKMIGRATE_PASSWORD=your_secure_password

CLICKMIGRATE_MIGRATION_DIRECTORY=migrations
CLICKMIGRATE_MIGRATION_TABLE=clickmigrate_history

Migration Naming

Migration files are executed in lexicographical order.

Example:

001_create_users.sql
002_add_email.sql
003_create_orders.sql
004_add_indexes.sql

Each migration is executed only once and recorded in the migration history table.


Commands

Command Description
clickmigrate init Initialize a migration project
clickmigrate revision -m "message" Create a new migration
clickmigrate status Show applied and pending migrations
clickmigrate migrate Apply pending migrations
clickmigrate migrate --dry-run Preview pending migrations
clickmigrate validate Validate migration checksums
clickmigrate version Show the installed ClickMigrate version
clickmigrate help Show the CLI help message

Requirements

  • Python 3.11+
  • A running ClickHouse server
  • HTTP interface enabled (default port 8123)

License

MIT License.

Metadata

Release files for ClickMigrate 1.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ClickMigrate 1.0.8
File Size Uploaded
clickmigrate-1.0.8.tar.gz 9.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ClickMigrate 1.0.8
File Interpreter ABI Platform
clickmigrate-1.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 20.3 kB

Release files / clickmigrate-1.0.8.tar.gz

Download URL clickmigrate-1.0.8.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
577bbb85b7a9913280921945d5ee5d60ae32d6f2c9f182e249715739b75e02d0
BLAKE2b-256 checksum
How to use checksums
8738e456967c3445b6d8c22f442dee4e466089e13c7bc1ad047ceebe80a1cbc2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.

Transparency log

Release files / clickmigrate-1.0.8-py3-none-any.whl

Download URL clickmigrate-1.0.8-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb6be71876dea2e9a978efc307981c3dbd866e0e954d5d9b7f7618f060f063d6
BLAKE2b-256 checksum
How to use checksums
dc849fe824b9e7f1456612015f962a0bb39891097fdefe2d41263bb216d3a539
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.8 This release

2 release files

1.0.3

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page