https://github.com/devflowinc/clickhouse-migrations
ClickHouse schema migration utility for Rust
https://github.com/devflowinc/clickhouse-migrations
Last synced: 2 days ago
JSON representation
ClickHouse schema migration utility for Rust
- Host: GitHub
- URL: https://github.com/devflowinc/clickhouse-migrations
- Owner: devflowinc
- License: mit
- Created: 2024-07-10T16:30:29.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-04-10T03:08:26.000Z (3 months ago)
- Last Synced: 2025-06-22T05:17:05.227Z (4 days ago)
- Language: Rust
- Homepage:
- Size: 43 KB
- Stars: 9
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Clickhouse Migration Tool (chm) - README
## Overview
The Clickhouse Migration Tool (`chm`) is a command-line interface (CLI) designed to help manage database migrations for Clickhouse. It allows users to set up migration configurations, generate new migrations, and run migrations in a stateful manner.
## Installation
To install the Clickhouse Migration Tool, you need to have Rust installed on your machine. If you don't already have it installed, you can install it with:
```sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```Then, you can install trieve from cargo:
```sh
cargo install chm
```After installing the tool, you can run the CLI using the `chm` command.
## Usage
### General Structure
```sh
chm [subcommand] [flags]
```### Commands and Subcommands
#### Setup
Initial setup of the migration tool. This command creates a folder to contain migrations and a `.toml` file with connection details. It will error if the migrations folder already exists.
```sh
chm setup --url --user --password --database
```- `--url` (Optional): Clickhouse URL. Will look for `CLICKHOUSE_URL` environment variable if not provided.
- `--user` (Optional): Clickhouse user. Will look for `CLICKHOUSE_USER` environment variable if not provided.
- `--password` (Optional): Clickhouse password. Will look for `CLICKHOUSE_PASSWORD` environment variable if not provided.
- `--database` (Optional): Clickhouse database. Will look for `CLICKHOUSE_DB` environment variable if not provided.#### Migration
Commands to handle migration operations.
##### Generate
Generates a new migration file with the specified name.
```sh
chm migration generate
```##### Run
Identifies and runs pending migrations.
```sh
chm migration run
```##### Redo
Reverts the latest migration and applies it again.
```sh
chm migration redo
```##### Revert
Reverts the last migration.
```sh
chm migration revert
```## Example
1. **Setup the Migration Tool**
```sh
chm setup --url http://localhost:8123 --user default --password password --database my_database
```2. **Generate a New Migration**
```sh
chm migration generate create_users_table
```3. **Run Pending Migrations**
```sh
chm migration run
```4. **Redo the Latest Migration**
```sh
chm migration redo
```5. **Revert the Last Migration**
```sh
chm migration revert
```## Contributing
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
## License
This project is licensed under the MIT License. See the LICENSE file for details.
## Contact
For any questions or issues, please open an issue on the GitHub repository or contact the maintainers.
---
This README provides a basic overview of the Clickhouse Migration Tool and its features. For detailed usage and examples, please refer to the command-specific help by running `chm --help`.