dialect/sql/schema: use the Atlas as state reader (#3314)

This commit is contained in:
Ariel Mashraki
2023-02-14 10:20:34 +02:00
committed by GitHub
parent 7aea5a82bc
commit 4c87e262a6
2 changed files with 35 additions and 2 deletions

View File

@@ -551,6 +551,13 @@ const (
// StateReader returns an atlas migrate.StateReader returning the state as described by the Ent table slice.
func (a *Atlas) StateReader(tables ...*Table) migrate.StateReaderFunc {
return func(context.Context) (*schema.Realm, error) {
if a.sqlDialect == nil {
drv, err := a.entDialect(a.driver)
if err != nil {
return nil, err
}
a.sqlDialect = drv
}
ts, err := a.tables(tables)
if err != nil {
return nil, err