Releases: anytoe/chsync
v0.3.0 — Correct DDL emission for materialized views and engine arguments
Fixes two cases where the diff path reconstructed CREATE statements from
column metadata alone and silently dropped clauses, producing changelogs
that did not match production when replayed. The snapshot path was
unaffected because it reads system.tables.create_table_query verbatim.
What's fixed
-
Engine arguments — loader parses the engine arg list from
engine_full
and stores it onTable.EngineArgs; generator emits
ENGINE = Engine(args). Previously, the version column on
ReplacingMergeTree(xo_received_at)(and equivalent args on Summing,
Collapsing, VersionedCollapsing) was dropped, breaking deduplication
semantics. Replication parameters fromShared*/Replicated*
engines are stripped to mirror existing engine-name normalization.
An engine-args change is treated like an engine change (drop + recreate). -
Materialized views — diffed as their own object kind, same shape as
dictionaries. The fullCREATE MATERIALIZED VIEW ... TO ... AS SELECT ...
is kept verbatim; body changes emit drop + recreate. Previously, MVs
were treated as ordinary tables and emitted as
CREATE TABLE ... ENGINE = MaterializedView, which is not executable
and dropped both theTOtarget and theAS SELECTbody. MV operations
are now emitted after all regular table operations so a fresh replay
can resolveTOtargets.
Changes
v0.2.0 - dictionaries, table settings, projections
Closes three gaps in the diff support matrix. Previously, schemas that
used any of these features round-tripped through chsync diff with the
clauses silently dropped — meaning a generated changelog applied to a
fresh environment produced tables that didn't match production.
What's covered now
- Dictionaries — diffed as their own object kind. CREATE DICTIONARY
bodies are kept verbatim; body changes emit drop + recreate. - Table settings — loader reads them from
system.tables.engine_full;
generator emitsALTER TABLE ... MODIFY SETTINGfor added/changed keys
andRESET SETTINGfor source-only keys. Immutable settings (e.g.
index_granularity) will be rejected by ClickHouse at apply time, which
is preferable to drop+recreate wiping data for a settings tweak. - Projections — loader reads from
system.projections; generator
emitsALTER TABLE ... DROP/ADD PROJECTION, and inlinesPROJECTION ...
clauses inCREATE TABLEfor new tables.MATERIALIZE PROJECTIONis
not emitted — backfilling historical data is an operator decision.
Changes
v0.1.3
snapshot --log <dir>records schema changes over time. Each run diffs the existing--outagainst the new schema (via temporary Docker containers) and writes a timestamped migration to<dir>/<YYYY-MM-DDTHHMMSS>.sql. First run writes the full schema as the initial entry. No-op runs write nothing.- Snapshot writes are now atomic —
schema.sqlis replaced via a sibling.tmp+ rename, so it's never left half-written if the process is interrupted. *clickhouse.Clientowns its lifecycle:Close()also tears down any temp Docker container it owns. No more separate cleanup function to thread through callers.clickhouse.Connectleaked a connection pool whenPingfailed afterOpensucceeded.examples/walkthrough now demonstrates the--logflow end-to-end.
v0.1.0
Initial release of chsync — a CLI tool that compares two ClickHouse schemas and generates SQL migration statements.
chsync snapshot— export a live instance schema to a .sql filechsync diff— compare two schemas (live instances or .sql files) and generate a migration
Supports create/drop/rename for databases, tables, and columns, plus modify column type and default. Uses Docker when .sql files are used as input.