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

Method QueryWithVersion

cli/migrate/migrate.go:630–668  ·  view source on GitHub ↗
(version uint64, data io.ReadCloser, skipExecution bool)

Source from the content-addressed store, hash-verified

628}
629
630func (m *Migrate) QueryWithVersion(version uint64, data io.ReadCloser, skipExecution bool) error {
631 var op herrors.Op = "migrate.Migrate.QueryWithVersion"
632 mode, err := m.databaseDrv.GetSetting("migration_mode")
633 if err != nil {
634 return herrors.E(op, err)
635 }
636
637 if mode != "true" {
638 return herrors.E(op, ErrNoMigrationMode)
639 }
640
641 if err := m.lock(); err != nil {
642 return herrors.E(op, err)
643 }
644
645 if !skipExecution {
646 if err := m.databaseDrv.Run(data, "meta", "", false); err != nil {
647 m.databaseDrv.ResetQuery()
648 if e := m.unlockErr(err); e != nil {
649 return herrors.E(op, e)
650 }
651 return nil
652 }
653 }
654
655 if version != 0 {
656 if err := m.databaseDrv.SetVersion(int64(version), false); err != nil {
657 m.databaseDrv.ResetQuery()
658 if e := m.unlockErr(err); e != nil {
659 return herrors.E(op, e)
660 }
661 return nil
662 }
663 }
664 if err := m.unlockErr(nil); err != nil {
665 return herrors.E(op, err)
666 }
667 return nil
668}
669
670// Steps looks at the currently active migration version.
671// It will migrate up if n > 0, and down if n < 0.

Callers 1

MigrateAPIFunction · 0.95

Calls 6

lockMethod · 0.95
unlockErrMethod · 0.95
GetSettingMethod · 0.65
RunMethod · 0.65
ResetQueryMethod · 0.65
SetVersionMethod · 0.65

Tested by

no test coverage detected