mirror of
https://github.com/ent/ent.git
synced 2026-05-04 00:20:58 +03:00
dialect/sql/schema: fix postgres index migration (#1351)
Fix PostgreSQL index migration when table_name = type_name. Closed #1344
This commit is contained in:
@@ -139,6 +139,19 @@ func (t *Table) index(name string) (*Index, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// hasIndex reports if the table has at least one index that matches the given names.
|
||||
func (t *Table) hasIndex(names ...string) bool {
|
||||
for i := range names {
|
||||
if names[i] == "" {
|
||||
continue
|
||||
}
|
||||
if _, ok := t.index(names[i]); ok {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// fk returns a table foreign-key by its symbol.
|
||||
// faster than map lookup for most cases.
|
||||
func (t *Table) fk(symbol string) (*ForeignKey, bool) {
|
||||
|
||||
Reference in New Issue
Block a user