Skip to content

Support :comment column option in migrations#282

Merged
ruslandoga merged 2 commits into
plausible:masterfrom
whatyouhide:comment-column-option
May 30, 2026
Merged

Support :comment column option in migrations#282
ruslandoga merged 2 commits into
plausible:masterfrom
whatyouhide:comment-column-option

Conversation

@whatyouhide
Copy link
Copy Markdown
Contributor

The Ecto migration DSL allows a :comment option. ClickHouse fully supports column comments, but the adapter previously honored only the table-level comment and the :default/:null column options, silently dropping :comment.

This wires a comment_expr/1 helper into column_options/2 (used by CREATE TABLE and ADD COLUMN) and into the :modify clause of column_change/2 (MODIFY COLUMN). The comment is emitted as an inline COMMENT '...' suffix after the type and any DEFAULT/NULL expressions, matching ClickHouse syntax.

Single quotes in the comment are escaped via Connection.escape_string/1 (the same helper used for string DEFAULT literals), producing valid SQL. Output is unchanged when :comment is absent.

cc @ruslandoga

The Ecto migration DSL allows a `:comment` option. ClickHouse fully supports column
comments, but the adapter previously honored only the table-level comment and
the `:default`/`:null` column options, silently dropping `:comment`.

This wires a `comment_expr/1` helper into `column_options/2` (used by CREATE
TABLE and ADD COLUMN) and into the `:modify` clause of `column_change/2`
(MODIFY COLUMN). The comment is emitted as an inline `COMMENT '...'` suffix
after the type and any DEFAULT/NULL expressions, matching ClickHouse syntax.

Single quotes in the comment are escaped via `Connection.escape_string/1`
(the same helper used for string DEFAULT literals), producing valid SQL.
Output is unchanged when `:comment` is absent.
Comment thread CHANGELOG.md Outdated
@ruslandoga ruslandoga self-requested a review May 30, 2026 14:54
@ruslandoga ruslandoga merged commit 4d43ff3 into plausible:master May 30, 2026
2 checks passed
@ruslandoga
Copy link
Copy Markdown
Collaborator

Thank you! Released as https://hex.pm/packages/ecto_ch/0.9.4

@whatyouhide whatyouhide deleted the comment-column-option branch June 2, 2026 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants