mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
dialect/entsql: add support for index-type annotation
This commit is contained in:
committed by
Ariel Mashraki
parent
d80f7cc41a
commit
fe2511fc8d
@@ -951,5 +951,22 @@ func (d *MySQL) atIndex(idx1 *Index, t2 *schema.Table, idx2 *schema.Index) error
|
||||
}
|
||||
idx2.AddParts(part)
|
||||
}
|
||||
if t, ok := indexType(idx1, dialect.MySQL); ok {
|
||||
idx2.AddAttrs(&mysql.IndexType{T: t})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func indexType(idx *Index, d string) (string, bool) {
|
||||
ant := idx.Annotation
|
||||
if ant == nil {
|
||||
return "", false
|
||||
}
|
||||
if ant.Type != "" {
|
||||
return idx.Annotation.Type, true
|
||||
}
|
||||
if ant.Types != nil && ant.Types[d] != "" {
|
||||
return ant.Types[d], true
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
@@ -779,5 +779,8 @@ func (d *Postgres) atIndex(idx1 *Index, t2 *schema.Table, idx2 *schema.Index) er
|
||||
}
|
||||
idx2.AddParts(&schema.IndexPart{C: c2})
|
||||
}
|
||||
if t, ok := indexType(idx1, dialect.Postgres); ok {
|
||||
idx2.AddAttrs(&postgres.IndexType{T: t})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user