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.
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.
- 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. - Project Initialization –
clickmigrate initautomatically creates apyproject.tomlconfiguration 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.
ClickMigrate requires Python 3.11+.
Install it using pip:
pip install ClickMigrateClickMigrate provides an Alembic-like CLI for managing your migration workflow.
Create the migration directory (default: migrations/) and generate a pyproject.toml configuration file with default settings if one does not already exist.
clickmigrate initGenerate 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.
View applied and pending migrations, including the version and name of each pending migration.
clickmigrate statusRun all pending migrations. Progress and execution time are displayed for each migration.
clickmigrate migratePreview the execution without applying changes:
clickmigrate migrate --dry-runVerify that previously applied migration files have not been modified.
clickmigrate validateDisplay the installed ClickMigrate version.
clickmigrate versionClickMigrate automatically searches for configuration files in your project root.
Supported formats (in priority order):
pyproject.toml(recommended)clickmigrate.jsonclickmigrate.yaml- Environment variables
[tool.clickmigrate]
host = "localhost"
port = 8123
database = "default"
username = "default"
password = "your_secure_password"
migration_directory = "migrations"
migration_table = "clickmigrate_history"{
"host": "localhost",
"port": 8123,
"database": "default",
"username": "default",
"password": "your_secure_password",
"migration_directory": "migrations",
"migration_table": "clickmigrate_history"
}host: localhost
port: 8123
database: default
username: default
password: your_secure_password
migration_directory: migrations
migration_table: clickmigrate_historyCLICKMIGRATE_HOST=localhost
CLICKMIGRATE_PORT=8123
CLICKMIGRATE_DATABASE=default
CLICKMIGRATE_USERNAME=default
CLICKMIGRATE_PASSWORD=your_secure_password
CLICKMIGRATE_MIGRATION_DIRECTORY=migrations
CLICKMIGRATE_MIGRATION_TABLE=clickmigrate_historyMigration 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.
| 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 |
- Python 3.11+
- A running ClickHouse server
- HTTP interface enabled (default port
8123)
MIT License.