A modern, simple database migration framework for ClickHouse.
Project description
ClickMigrate
A modern, simple, and reliable database migration framework for ClickHouse, inspired by Alembic.
ClickMigrate is designed to be lightweight and easy to understand. It avoids over-engineered abstractions, offering a straightforward CLI and a clean Python API for managing your ClickHouse schema evolutions.
Features
- SQL-based Migrations – Write your migrations in plain
.sqlfiles. - 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. - 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.
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/).
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 how many migrations have been applied and how many are pending.
clickmigrate status
4. Apply Migrations
Run all pending migrations.
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
Configuration
ClickMigrate automatically searches for configuration files in your project root.
Supported formats (in priority order):
pyproject.toml(recommended)clickmigrate.jsonclickmigrate.yaml- Environment variables
Option A: pyproject.toml (Recommended)
[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 migration status |
clickmigrate migrate |
Apply pending migrations |
clickmigrate migrate --dry-run |
Preview pending migrations |
clickmigrate validate |
Validate migration checksums |
Requirements
- Python 3.11+
- A running ClickHouse server
- HTTP interface enabled (default port
8123)
License
MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clickmigrate-1.0.0.tar.gz.
File metadata
- Download URL: clickmigrate-1.0.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6effbcfab34175d52848bc9b530b4e81ebec7bf3a17cfe28b1e41acf87937570
|
|
| MD5 |
97edfc5fc3ae56b5c8a9ba1e50eee2f2
|
|
| BLAKE2b-256 |
85dbce96556d3dfa3092a68ea651452ef838b05f5bf5e5054e6f73e0a0260b2e
|
Provenance
The following attestation bundles were made for clickmigrate-1.0.0.tar.gz:
Publisher:
publish.yml on QueueForge/ClickMigrate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clickmigrate-1.0.0.tar.gz -
Subject digest:
6effbcfab34175d52848bc9b530b4e81ebec7bf3a17cfe28b1e41acf87937570 - Sigstore transparency entry: 2026106593
- Sigstore integration time:
-
Permalink:
QueueForge/ClickMigrate@94b3099a1fc12c9fbb3a45ce814e26b25df11ad6 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/QueueForge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@94b3099a1fc12c9fbb3a45ce814e26b25df11ad6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file clickmigrate-1.0.0-py3-none-any.whl.
File metadata
- Download URL: clickmigrate-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d64e82f2a8b0476cf41811dcbd3679a23b640c0bf26a7aefc2ee4de889a0fa6
|
|
| MD5 |
75e104d2a9a3e6772441fc19f959a5d2
|
|
| BLAKE2b-256 |
4d6072ae0ca7ee356ee930e362fd4675dabe7a08d7f84004f62524155225a446
|
Provenance
The following attestation bundles were made for clickmigrate-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on QueueForge/ClickMigrate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clickmigrate-1.0.0-py3-none-any.whl -
Subject digest:
9d64e82f2a8b0476cf41811dcbd3679a23b640c0bf26a7aefc2ee4de889a0fa6 - Sigstore transparency entry: 2026106690
- Sigstore integration time:
-
Permalink:
QueueForge/ClickMigrate@94b3099a1fc12c9fbb3a45ce814e26b25df11ad6 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/QueueForge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@94b3099a1fc12c9fbb3a45ce814e26b25df11ad6 -
Trigger Event:
push
-
Statement type: