github.com/bdollma-te/migrate/v4@v4.17.0-clickv2/database/clickhouse/README.md (about) 1 # ClickHouse 2 3 `clickhouse://username:password@host:port/database?dial_timeout=200ms&max_execution_time=60&x-multi-statement=true` 4 5 For more parameters refer to the original [Clickhouse-Go](https://github.com/ClickHouse/clickhouse-go?tab=readme-ov-file#dsn) 6 7 | URL Query | Description | 8 |------------|-------------| 9 | `x-migrations-table`| Name of the migrations table | 10 | `x-migrations-table-engine`| Engine to use for the migrations table, defaults to TinyLog | 11 | `x-cluster-name` | Name of cluster for creating `schema_migrations` table cluster wide | 12 | `database` | The name of the database to connect to | 13 | `username` | The user to sign in as | 14 | `password` | The user's password | 15 | `host` | The host to connect to. | 16 | `port` | The port to bind to. | 17 | `x-multi-statement` | false | Enable multiple statements to be ran in a single migration (See note below) | 18 19 ## Notes 20 21 * 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: 22 * 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. 23 * The queries are not executed in any sort of transaction/batch, meaning you are responsible for fixing partial migrations. 24 * 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`. 25 * 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`: 26 * 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). 27 * 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. 28 * If you want to create database inside the migration, you should know, that table which will manage migrations `schema-migrations table` will be in `default` table, so you can't use `USE <database_name>` inside migration. In this case you may not specify the database in the connection string (example you can find [here](examples/migrations/003_create_database.up.sql))