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

Method Up

cli/migrate/migrate.go:715–754  ·  view source on GitHub ↗

Up looks at the currently active migration version and will migrate all the way up (applying all up migrations).

()

Source from the content-addressed store, hash-verified

713// Up looks at the currently active migration version
714// and will migrate all the way up (applying all up migrations).
715func (m *Migrate) Up() error {
716 var op herrors.Op = "migrate.Migrate.Up"
717 mode, err := m.databaseDrv.GetSetting("migration_mode")
718 if err != nil {
719 return herrors.E(op, err)
720 }
721
722 if mode != "true" {
723 return herrors.E(op, ErrNoMigrationMode)
724 }
725
726 if err := m.lock(); err != nil {
727 return herrors.E(op, err)
728 }
729
730 curVersion, dirty, err := m.databaseDrv.Version()
731 if err != nil {
732 return herrors.E(op, err)
733 }
734
735 if dirty {
736 return herrors.E(op, ErrDirty{curVersion})
737 }
738
739 ret := make(chan interface{}, m.PrefetchMigrations)
740 bar := newProgressBar(applyingMigrationsMessage, m.stderr, m.ProgressBarLogs)
741 go m.readUp(-1, ret, bar)
742
743 if m.DryRun {
744 if err := m.unlockErr(m.runDryRun(ret)); err != nil {
745 return herrors.E(op, err)
746 }
747 return nil
748 } else {
749 if err := m.unlockErr(m.runMigrations(ret, bar)); err != nil {
750 return herrors.E(op, err)
751 }
752 return nil
753 }
754}
755
756// Down looks at the currently active migration version
757// and will migrate all the way down (applying all down migrations).

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected