github.com/scraniel/migrate@v0.0.0-20230320185700-339088f36cee/database/clickhouse/README.md (about)

     1  # ClickHouse
     2  
     3  `clickhouse://host:port?username=user&password=password&database=clicks&x-multi-statement=true`
     4  
     5  | URL Query  | Description |
     6  |------------|-------------|
     7  | `x-migrations-table`| Name of the migrations table |
     8  | `x-migrations-table-engine`| Engine to use for the migrations table, defaults to TinyLog |
     9  | `x-cluster-name` | Name of cluster for creating `schema_migrations` table cluster wide |
    10  | `database` | The name of the database to connect to |
    11  | `username` | The user to sign in as |
    12  | `password` | The user's password |
    13  | `host` | The host to connect to. |
    14  | `port` | The port to bind to. |
    15  | `x-multi-statement` | false | Enable multiple statements to be ran in a single migration (See note below) |
    16  
    17  ## Notes
    18  
    19  * The Clickhouse driver does not natively support executing multipe statements in a single query. To allow for multiple statements in a single migration, you can use the `x-multi-statement` param. There are two important caveats:
    20    * This mode splits the migration text into separately-executed statements by a semi-colon `;`. Thus `x-multi-statement` cannot be used when a statement in the migration contains a string with a semi-colon.
    21    * The queries are not executed in any sort of transaction/batch, meaning you are responsible for fixing partial migrations.
    22  * Using the default TinyLog table engine for the schema_versions table prevents backing up the table if using the [clickhouse-backup](https://github.com/AlexAkulov/clickhouse-backup) tool. If backing up the database with make sure the migrations are run with `x-migrations-table-engine=MergeTree`.
    23  * Clickhouse cluster mode is not officially supported, since it's not tested right now, but you can try enabling `schema_migrations` table replication by specifying a `x-cluster-name`:
    24    * When `x-cluster-name` is specified, `x-migrations-table-engine` also should be specified. See the docs regarding [replicated table engines](https://clickhouse.tech/docs/en/engines/table-engines/mergetree-family/replication/#table_engines-replication).
    25    * When `x-cluster-name` is specified, only the `schema_migrations` table is replicated across the cluster. You still need to write your migrations so that the application tables are replicated within the cluster.