# PyClickHouseMigrator

> Lightweight, ORM-free Python CLI for ClickHouse schema migrations.
> Advisory locking for concurrent execution protection.
> Supports single-node and cluster (ON CLUSTER) modes with replicated service tables.

- Python 3.11+, depends only on `clickhouse-driver` and `click`
- Not an ORM, not a framework — just a migration runner
- Migrations are `.py` files with `up()` and `rollback()` functions returning SQL strings
- CLI entry point: `migrator` (PyPI package: `py-clickhouse-migrator`)
- Version: 1.0.0
- License: MIT

## Docs

- [README](https://raw.githubusercontent.com/Maksim-Burtsev/PyClickHouseMigrator/master/README.md): Installation, quick start, CLI reference, configuration, cluster support, limitations
- [Changelog](https://raw.githubusercontent.com/Maksim-Burtsev/PyClickHouseMigrator/master/CHANGELOG.txt): Version history

## Source

- [cli.py](https://raw.githubusercontent.com/Maksim-Burtsev/PyClickHouseMigrator/master/py_clickhouse_migrator/cli.py): Click CLI — commands: init, new, up, rollback, show, repair, force-unlock, lock-info
- [migrator.py](https://raw.githubusercontent.com/Maksim-Burtsev/PyClickHouseMigrator/master/py_clickhouse_migrator/migrator.py): Core migration logic — apply, rollback, checksum validation, status display
- [lock.py](https://raw.githubusercontent.com/Maksim-Burtsev/PyClickHouseMigrator/master/py_clickhouse_migrator/lock.py): Advisory lock using ReplacingMergeTree with TTL and retry
- [__init__.py](https://raw.githubusercontent.com/Maksim-Burtsev/PyClickHouseMigrator/master/py_clickhouse_migrator/__init__.py): Public API exports (Migrator, MigrationLock, exceptions, helpers)
- [pyproject.toml](https://raw.githubusercontent.com/Maksim-Burtsev/PyClickHouseMigrator/master/pyproject.toml): Project metadata, dependencies, tool config

## Optional

- [License](https://raw.githubusercontent.com/Maksim-Burtsev/PyClickHouseMigrator/master/LICENCE.txt): MIT License
