mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
dialect/sql/schema: avoid setting the primary key when no primary key is present (#3114)
* dialect/sql: avoid setting the primary key when no primary key is present * fix tests * adds comment
This commit is contained in:
@@ -979,7 +979,10 @@ func (a *Atlas) aIndexes(et *Table, at *schema.Table) error {
|
||||
}
|
||||
pk = append(pk, c2)
|
||||
}
|
||||
at.SetPrimaryKey(schema.NewPrimaryKey(pk...))
|
||||
// CreateFunc might clear the primary keys.
|
||||
if len(pk) > 0 {
|
||||
at.SetPrimaryKey(schema.NewPrimaryKey(pk...))
|
||||
}
|
||||
// Rest of indexes.
|
||||
for _, idx1 := range et.Indexes {
|
||||
idx2 := schema.NewIndex(idx1.Name).
|
||||
|
||||
Reference in New Issue
Block a user