entc/gen: merge list of entsql annotation to one (#928)

This commit is contained in:
Ariel Mashraki
2020-11-08 10:57:31 +02:00
committed by GitHub
parent 6b2673f82d
commit dea48a78ea
4 changed files with 46 additions and 10 deletions

View File

@@ -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{