mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
dialect/entsql: supports setting SQL column comments (#3191)
* feat: Add column comment in SQL DDL, using EntSQL annotations to achieve it. * Update annotation.go * fix lint * Add table primary key column comment * entsql.Comment(string) is unnecessary * entc/gen: minor changes to entsql.WithComments + add tests Co-authored-by: chenghonour <wantto@outlook.com>
This commit is contained in:
@@ -912,6 +912,9 @@ func (a *Atlas) aColumns(et *Table, at *schema.Table) error {
|
||||
if c1.Collation != "" {
|
||||
c2.SetCollation(c1.Collation)
|
||||
}
|
||||
if c1.Comment != "" {
|
||||
c2.SetComment(c1.Comment)
|
||||
}
|
||||
if err := a.sqlDialect.atTypeC(c1, c2); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -295,6 +295,7 @@ type Column struct {
|
||||
typ string // row column type (used for Rows.Scan).
|
||||
indexes Indexes // linked indexes.
|
||||
foreign *ForeignKey // linked foreign-key.
|
||||
Comment string // column comment.
|
||||
}
|
||||
|
||||
// Expr represents a raw expression. It is used to distinguish between
|
||||
|
||||
Reference in New Issue
Block a user