mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: merge list of entsql annotation to one (#928)
This commit is contained in:
@@ -16,7 +16,24 @@ type Annotation struct {
|
||||
// Table: "Users",
|
||||
// }
|
||||
//
|
||||
Table string
|
||||
Table string `json:"table,omitempty"`
|
||||
|
||||
// Charset defines the character-set of the table. For example:
|
||||
//
|
||||
// entsql.Annotation{
|
||||
// Charset: "utf8mb4",
|
||||
// }
|
||||
//
|
||||
Charset string `json:"charset,omitempty"`
|
||||
|
||||
// Collation defines the collation of the table (a set of rules for comparing
|
||||
// characters in a character set). For example:
|
||||
//
|
||||
// entsql.Annotation{
|
||||
// Collation: "utf8mb4_bin",
|
||||
// }
|
||||
//
|
||||
Collation string `json:"collation,omitempty"`
|
||||
}
|
||||
|
||||
// Name describes the annotation name.
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/facebook/ent/dialect/entsql"
|
||||
"github.com/facebook/ent/dialect/sql"
|
||||
"github.com/facebook/ent/schema/field"
|
||||
)
|
||||
@@ -33,6 +34,7 @@ type Table struct {
|
||||
Indexes []*Index
|
||||
PrimaryKey []*Column
|
||||
ForeignKeys []*ForeignKey
|
||||
Annotation *entsql.Annotation
|
||||
}
|
||||
|
||||
// NewTable returns a new table with the given name.
|
||||
@@ -63,6 +65,12 @@ func (t *Table) AddColumn(c *Column) *Table {
|
||||
return t
|
||||
}
|
||||
|
||||
// SetAnnotation the entsql.Annotation on the table.
|
||||
func (t *Table) SetAnnotation(ant *entsql.Annotation) *Table {
|
||||
t.Annotation = ant
|
||||
return t
|
||||
}
|
||||
|
||||
// AddIndex creates and adds a new index to the table from the given options.
|
||||
func (t *Table) AddIndex(name string, unique bool, columns []string) *Table {
|
||||
return t.addIndex(&Index{
|
||||
|
||||
Reference in New Issue
Block a user