mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
dialect/sql/schema: added foreign keys to postgres inspect (#1493)
* Added foreign keys to postgres inspect * Update dialect/sql/schema/inspect.go Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com> * Update dialect/sql/schema/inspect.go Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com> * added unit test * fixed interface * moved import back * fixing tests * Update dialect/sql/schema/inspect.go Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com> * Update dialect/sql/schema/postgres.go Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com> * Update dialect/sql/schema/postgres.go Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com> * pr feedback * added m2m test case * converted to unit tests Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com>
This commit is contained in:
@@ -62,6 +62,15 @@ func (i *Inspector) Tables(ctx context.Context) ([]*Table, error) {
|
||||
}
|
||||
tables = append(tables, t)
|
||||
}
|
||||
|
||||
fki, ok := i.sqlDialect.(interface {
|
||||
foreignKeys(context.Context, dialect.Tx, []*Table) error
|
||||
})
|
||||
if ok {
|
||||
if err := fki.foreignKeys(ctx, tx, tables); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return tables, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user