MCPcopy
hub / github.com/hasura/graphql-engine / Steps

Method Steps

cli/migrate/migrate.go:672–711  ·  view source on GitHub ↗

Steps looks at the currently active migration version. It will migrate up if n > 0, and down if n < 0.

(n int64)

Source from the content-addressed store, hash-verified

670// Steps looks at the currently active migration version.
671// It will migrate up if n > 0, and down if n < 0.
672func (m *Migrate) Steps(n int64) error {
673 var op herrors.Op = "migrate.Migrate.Steps"
674 mode, err := m.databaseDrv.GetSetting("migration_mode")
675 if err != nil {
676 return herrors.E(op, err)
677 }
678
679 if mode != "true" {
680 return herrors.E(op, ErrNoMigrationMode)
681 }
682
683 if n == 0 {
684 return herrors.E(op, ErrNoChange)
685 }
686
687 if err := m.lock(); err != nil {
688 return herrors.E(op, err)
689 }
690
691 ret := make(chan interface{}, m.PrefetchMigrations)
692 bar := newProgressBar(applyingMigrationsMessage, m.stderr, m.ProgressBarLogs)
693
694 if n > 0 {
695 go m.readUp(n, ret, bar)
696 } else {
697 go m.readDown(-n, ret, bar)
698 }
699
700 if m.DryRun {
701 if err := m.unlockErr(m.runDryRun(ret)); err != nil {
702 return herrors.E(op, err)
703 }
704 return nil
705 } else {
706 if err := m.unlockErr(m.runMigrations(ret, bar)); err != nil {
707 return herrors.E(op, err)
708 }
709 return nil
710 }
711}
712
713// Up looks at the currently active migration version
714// and will migrate all the way up (applying all up migrations).

Callers 2

UpCmdFunction · 0.80
DownCmdFunction · 0.80

Calls 8

lockMethod · 0.95
readUpMethod · 0.95
readDownMethod · 0.95
unlockErrMethod · 0.95
runDryRunMethod · 0.95
runMigrationsMethod · 0.95
newProgressBarFunction · 0.85
GetSettingMethod · 0.65

Tested by

no test coverage detected