pressly / goose

A database migration tool. Supports SQL migrations and Go functions.
http://pressly.github.io/goose/
Other
7.16k stars 523 forks source link

Add clickhouse-replicated dialect #809

Closed chapsuk closed 4 days ago

chapsuk commented 3 months ago

This PR introduces a new clickhouse-replicated dialect, and here’s why it’s needed:

These differences between a single-node ClickHouse instance and a replicated cluster are why we’re adding this new dialect.

Added the environment variable GOOSE_CLICKHOUSE_CLUSTER_NAME (default: {cluster}) allows to set Clickhouse cluster name

vdksystem commented 2 days ago

@yakovlevmichaelv are you planning on implementing store interface? it's almost a year since someone tried to add real support for clickhouse and we still don't have it. I think @mfridman will agree that when we talk about clickhouse and db migrations it's 99.99% about production, where there is almost no sense to introduce analytical highly scalable database with single node version. So for now goose clickhouse support is only for dev environments.

For now I manually initialize version tables (in my case multiple)

CREATE TABLE goose_db_version on cluster analytics
(
    `version_id` Int64,
    `is_applied` UInt8,
    `date` Date DEFAULT now(),
    `tstamp` DateTime DEFAULT now()
)
ENGINE = KeeperMap('/goose_db_version_edi_service')
PRIMARY KEY version_id;
insert into goose_db_version values(0, 1, toDate(now()), now())