entc/gen: add support for indexing id fields (#991)

* fix: allow indexes to be created on ID field

* test: add case for id field

* remove extraneous nil check

* change add primary method

* add integration test for mixin id

* go generate

* add default for default

* make linter happy

* invert if statement

* add default index to card integration test

* add index on default id, mixin id, and composite index

* go generate
This commit is contained in:
Nathaniel Peiffer
2020-12-18 02:58:01 +11:00
committed by GitHub
parent 70fbcb24e5
commit 754e89c6ae
21 changed files with 2632 additions and 28 deletions

View File

@@ -47,7 +47,7 @@ func NewTable(name string) *Table {
// AddPrimary adds a new primary key to the table.
func (t *Table) AddPrimary(c *Column) *Table {
t.Columns = append(t.Columns, c)
t.AddColumn(c)
t.PrimaryKey = append(t.PrimaryKey, c)
return t
}