diff --git a/pkg/migrate/main.go b/pkg/migrate/main.go index 693fe8902..5bd6ec694 100644 --- a/pkg/migrate/main.go +++ b/pkg/migrate/main.go @@ -17,6 +17,7 @@ import ( "github.com/cortezaproject/corteza-server/pkg/migrate/types" sysRepo "github.com/cortezaproject/corteza-server/system/repository" sysTypes "github.com/cortezaproject/corteza-server/system/types" + "github.com/schollz/progressbar/v2" ) var ( @@ -214,9 +215,16 @@ func (m *Migrator) MakeAcyclic() { // processess migration nodes and migrates the data from the provided source files func (m *Migrator) Migrate(ctx context.Context, users map[string]uint64) error { + fmt.Println("(•_•)") + fmt.Println("(-•_•)>⌐■-■") + fmt.Println("(⌐■_■)") + fmt.Print("\n\n\n") + db := repository.DB(ctx) repoRecord := repository.Record(ctx, db) + bar := progressbar.New(len(m.nodes)) + return db.Transaction(func() (err error) { for len(m.Leafs) > 0 { var wg sync.WaitGroup @@ -226,7 +234,7 @@ func (m *Migrator) Migrate(ctx context.Context, users map[string]uint64) error { wg.Add(1) // migrate & update leaf nodes - go n.Migrate(repoRecord, users, &wg, ch) + go n.Migrate(repoRecord, users, &wg, ch, bar) } wg.Wait() diff --git a/pkg/migrate/types/node.go b/pkg/migrate/types/node.go index 39a2292df..7b1ba149e 100644 --- a/pkg/migrate/types/node.go +++ b/pkg/migrate/types/node.go @@ -76,8 +76,9 @@ func (n *Node) addMap(key string, m Map) { } // does the actual data migration for the given node -func (n *Node) Migrate(repoRecord repository.RecordRepository, users map[string]uint64, wg *sync.WaitGroup, ch chan PostProc) { +func (n *Node) Migrate(repoRecord repository.RecordRepository, users map[string]uint64, wg *sync.WaitGroup, ch chan PostProc, bar *progressbar.ProgressBar) { defer wg.Done() + defer bar.Add(1) fmt.Printf("node.migrate > %s\n", n.Stringify()) var err error