()
| 42 | } |
| 43 | |
| 44 | func (m *migratorImpl) loadExecuted() errors.Error { |
| 45 | db := m.basicRes.GetDal() |
| 46 | // make sure migration_history table exists |
| 47 | err := db.AutoMigrate(&MigrationHistory{}) |
| 48 | if err != nil { |
| 49 | return errors.Default.Wrap(err, "error performing migrations") |
| 50 | } |
| 51 | // load executed scripts into memory |
| 52 | m.executed = make(map[string]bool) |
| 53 | var records []MigrationHistory |
| 54 | err = db.All(&records) |
| 55 | if err != nil { |
| 56 | return errors.Default.Wrap(err, "error finding migration history records") |
| 57 | } |
| 58 | for _, record := range records { |
| 59 | scriptId := getScriptId(record.ScriptName, record.ScriptVersion) |
| 60 | m.executed[scriptId] = true |
| 61 | } |
| 62 | return nil |
| 63 | } |
| 64 | |
| 65 | // Register a MigrationScript to the Migrator with comment message |
| 66 | func (m *migratorImpl) Register(scripts []plugin.MigrationScript, comment string) { |
no test coverage detected