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

Method Migrate

cli/migrate/migrate.go:599–628  ·  view source on GitHub ↗

Migrate looks at the currently active migration version, then migrates either up or down to the specified version.

(version uint64, direction string)

Source from the content-addressed store, hash-verified

597// Migrate looks at the currently active migration version,
598// then migrates either up or down to the specified version.
599func (m *Migrate) Migrate(version uint64, direction string) error {
600 var op herrors.Op = "migrate.Migrate.Migrate"
601 mode, err := m.databaseDrv.GetSetting("migration_mode")
602 if err != nil {
603 return herrors.E(op, err)
604 }
605
606 if mode != "true" {
607 return herrors.E(op, ErrNoMigrationMode)
608 }
609
610 if err := m.lock(); err != nil {
611 return herrors.E(op, err)
612 }
613
614 ret := make(chan interface{}, m.PrefetchMigrations)
615 bar := newProgressBar(applyingMigrationsMessage, m.stderr, m.ProgressBarLogs)
616 go m.read(version, direction, ret, bar)
617 if m.DryRun {
618 if e := m.unlockErr(m.runDryRun(ret)); e != nil {
619 return herrors.E(op, e)
620 }
621 return nil
622 } else {
623 if e := m.unlockErr(m.runMigrations(ret, bar)); e != nil {
624 return herrors.E(op, e)
625 }
626 return nil
627 }
628}
629
630func (m *Migrate) QueryWithVersion(version uint64, data io.ReadCloser, skipExecution bool) error {
631 var op herrors.Op = "migrate.Migrate.QueryWithVersion"

Callers 1

GotoCmdFunction · 0.80

Calls 7

lockMethod · 0.95
readMethod · 0.95
unlockErrMethod · 0.95
runDryRunMethod · 0.95
runMigrationsMethod · 0.95
newProgressBarFunction · 0.85
GetSettingMethod · 0.65

Tested by

no test coverage detected