Migrate looks at the currently active migration version, then migrates either up or down to the specified version.
(version uint64, direction string)
| 597 | // Migrate looks at the currently active migration version, |
| 598 | // then migrates either up or down to the specified version. |
| 599 | func (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 | |
| 630 | func (m *Migrate) QueryWithVersion(version uint64, data io.ReadCloser, skipExecution bool) error { |
| 631 | var op herrors.Op = "migrate.Migrate.QueryWithVersion" |
no test coverage detected