github.com/wawandco/oxplugins@v0.7.11/tools/pop/migrate/up.go (about) 1 package migrate 2 3 import ( 4 "context" 5 6 "github.com/gobuffalo/pop/v5" 7 ) 8 9 // Run will run migrations on the current folder, it will look for the 10 // migrations folder and attempt to run the migrations using internal 11 // pop tooling 12 func (mu *Command) RunUp() error { 13 pop.SetLogger(mu.Log) 14 15 conn := pop.Connections[mu.connectionName] 16 if conn == nil { 17 return ErrCouldNotFindConnection 18 } 19 20 mig, err := pop.NewMigrationBox(mu.migrations, conn) 21 if err != nil { 22 return err 23 } 24 25 _, err = mig.UpTo(mu.steps) 26 return err 27 } 28 29 func (mu *Command) RunBeforeTest(ctx context.Context, root string, args []string) error { 30 pop.SetLogger(mu.Log) 31 32 conn := pop.Connections["test"] 33 if conn == nil { 34 return ErrCouldNotFindConnection 35 } 36 37 mig, err := pop.NewMigrationBox(mu.migrations, conn) 38 if err != nil { 39 return err 40 } 41 42 err = mig.Up() 43 return err 44 }