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:
Ciaran Liedeman
2021-04-26 14:32:12 +02:00
committed by GitHub
parent 43e74a334f
commit b20d521593
4 changed files with 280 additions and 9 deletions

View File

@@ -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
}