dbmate icon indicating copy to clipboard operation
dbmate copied to clipboard

Clickhouse schema_migrations table doesn't support cluster wide replication

Open oshankkumar opened this issue 3 years ago • 2 comments

My migrations look like this

CREATE TABLE company_db.events ON CLUSTER 'company_cluster' (
    time DateTime,
    uid  Int64,
    type LowCardinality(String)
)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{cluster}/{shard}/table', '{replica}')
PARTITION BY toDate(time)
ORDER BY (uid);

After running the migration I'm expecting schema_migrations table to be replicated across the cluster , So that I've a consistent schema migration information across cluster

golang-migrate solved this issue by specifying x-cluster-name query parameter in DSN string.

oshankkumar avatar Jan 21 '22 15:01 oshankkumar

Seems it wouldn't be hard to add such support in dbmate, just need some cluster to test against. Is there a nice way to spin up a cluster on a local machine?

Flamefork avatar Apr 19 '22 05:04 Flamefork

You can easily spin up a cluster on local machine using docker compose. Please check this repo https://github.com/tetafro/clickhouse-cluster for reference.

oshankkumar avatar Apr 22 '22 08:04 oshankkumar