Support :comment column option in migrations#282
Merged
Conversation
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.
ruslandoga
reviewed
May 30, 2026
ruslandoga
approved these changes
May 30, 2026
Collaborator
|
Thank you! Released as https://hex.pm/packages/ecto_ch/0.9.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Ecto migration DSL allows a
:commentoption. ClickHouse fully supports column comments, but the adapter previously honored only the table-level comment and the:default/:nullcolumn options, silently dropping:comment.This wires a
comment_expr/1helper intocolumn_options/2(used by CREATE TABLE and ADD COLUMN) and into the:modifyclause ofcolumn_change/2(MODIFY COLUMN). The comment is emitted as an inlineCOMMENT '...'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:commentis absent.cc @ruslandoga