18 releases

0.1.17 Aug 24, 2024
0.1.16 Aug 22, 2024
0.1.8 Jul 19, 2024

#1680 in Database interfaces

Download history 42/week @ 2024-07-27 57/week @ 2024-08-03 203/week @ 2024-08-10 762/week @ 2024-08-17 247/week @ 2024-08-24 67/week @ 2024-08-31 3/week @ 2024-09-07 7/week @ 2024-09-14 127/week @ 2024-09-21 117/week @ 2024-09-28 18/week @ 2024-10-05 75/week @ 2024-10-12 82/week @ 2024-10-19 279/week @ 2024-10-26 253/week @ 2024-11-02 20/week @ 2024-11-09

643 downloads per month

MIT license

20KB
421 lines

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:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Then, you can install trieve from cargo:

cargo install chm

After installing the tool, you can run the CLI using the chm command.

Usage

General Structure

chm <command> [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.

chm setup --url <CLICKHOUSE_URL> --user <CLICKHOUSE_USER> --password <CLICKHOUSE_PASSWORD> --database <CLICKHOUSE_DB>
  • --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.

chm migration generate <MIGRATION_NAME>
Run

Identifies and runs pending migrations.

chm migration run
Redo

Reverts the latest migration and applies it again.

chm migration redo
Revert

Reverts the last migration.

chm migration revert

Example

  1. Setup the Migration Tool

    chm setup --url http://localhost:8123 --user default --password password --database my_database
    
  2. Generate a New Migration

    chm migration generate create_users_table
    
  3. Run Pending Migrations

    chm migration run
    
  4. Redo the Latest Migration

    chm migration redo
    
  5. Revert the Last Migration

    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 <command> --help.

Dependencies

~12–22MB
~307K SLoC