mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
dialect/sql/schema: allow setting table comments (#3365)
This commit is contained in:
@@ -872,6 +872,9 @@ func (a *Atlas) tables(tables []*Table) ([]*schema.Table, error) {
|
||||
ts := make([]*schema.Table, len(tables))
|
||||
for i, et := range tables {
|
||||
at := schema.NewTable(et.Name)
|
||||
if et.Comment != "" {
|
||||
at.SetComment(et.Comment)
|
||||
}
|
||||
a.sqlDialect.atTable(et, at)
|
||||
if a.universalID && et.Name != TypeTable && len(et.PrimaryKey) == 1 {
|
||||
r, err := a.pkRange(et)
|
||||
|
||||
@@ -36,6 +36,7 @@ type Table struct {
|
||||
PrimaryKey []*Column
|
||||
ForeignKeys []*ForeignKey
|
||||
Annotation *entsql.Annotation
|
||||
Comment string
|
||||
}
|
||||
|
||||
// NewTable returns a new table with the given name.
|
||||
@@ -46,6 +47,12 @@ func NewTable(name string) *Table {
|
||||
}
|
||||
}
|
||||
|
||||
// SetComment sets the table comment.
|
||||
func (t *Table) SetComment(c string) *Table {
|
||||
t.Comment = c
|
||||
return t
|
||||
}
|
||||
|
||||
// AddPrimary adds a new primary key to the table.
|
||||
func (t *Table) AddPrimary(c *Column) *Table {
|
||||
c.Key = PrimaryKey
|
||||
@@ -295,7 +302,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.
|
||||
Comment string // optional column comment.
|
||||
}
|
||||
|
||||
// Expr represents a raw expression. It is used to distinguish between
|
||||
|
||||
Reference in New Issue
Block a user