Generates ClickHouse CREATE TABLE statements from Ash resources.
ClickHouse tables require an engine and an ORDER BY key. This module maps
Ash primary keys and attributes to ClickHouse column definitions and produces
a CREATE TABLE IF NOT EXISTS statement using the engine configured in the
resource's clickhouse DSL block.
Summary
Functions
Generates ALTER TABLE ... ADD INDEX IF NOT EXISTS statements for indexes
configured on the resource but not yet present in ClickHouse, and detects
configured indexes whose definition differs from what's actually stored.
Generates ALTER TABLE ... ADD COLUMN IF NOT EXISTS statements for attributes
that exist on the resource but not yet in the table. This is a minimal schema
evolution pass: it adds new columns but does not drop or alter existing ones.
Generates the CREATE TABLE SQL for a resource.
Generates all migration statements (table creation) for a list of resources.
Functions
Generates ALTER TABLE ... ADD INDEX IF NOT EXISTS statements for indexes
configured on the resource but not yet present in ClickHouse, and detects
configured indexes whose definition differs from what's actually stored.
Returns {statements, warnings}:
statements— safe, additiveADD INDEX IF NOT EXISTSstatements for indexes that don't exist yet.warnings— human-readable strings for indexes that exist under the same name but with a differenttypeorexpressionthan configured. These are not auto-corrected: ClickHouse requiresDROP INDEX+ADD INDEXto change a data-skipping index in place, and doing that automatically risks silently discarding a built index on a large table without the operator's knowledge. The warning tells you what to run manually.
Comparison of expression is best-effort: ClickHouse normalizes stored
expressions (whitespace, sometimes backtick quoting, occasionally constant
folding) so it may not match your DSL string byte-for-byte even when they're
semantically identical. When in doubt, treat a type mismatch as
authoritative and double-check expression mismatches by hand before acting
on them.
Generates ALTER TABLE ... ADD COLUMN IF NOT EXISTS statements for attributes
that exist on the resource but not yet in the table. This is a minimal schema
evolution pass: it adds new columns but does not drop or alter existing ones.
Returns an empty list when the table does not exist yet (the CREATE TABLE statement handles initial creation) or when there are no new columns.
Generates the CREATE TABLE SQL for a resource.
Generates all migration statements (table creation) for a list of resources.