func Downgrade(c *DatabaseConfig) (err error) { var m *gomigrate.Migrator m, err = getMigrator(c) if err != nil { fmt.Println(err) return } err = m.RollbackAll() return }
func Upgrade(c *DatabaseConfig) (err error) { var m *gomigrate.Migrator m, err = getMigrator(c) if err != nil { fmt.Println(err) return } err = m.Migrate() return }
func (a *App) missingMigrations(migrator gomigrate.Migrator) bool { migrations := migrator.Migrations(-1) missing := false for _, m := range migrations { if m.Status == gomigrate.Inactive { fmt.Println("Missing Migration: ", m.Name) missing = true } } return missing }
// Migrate migrates database func (a *App) Migrate(migrator gomigrate.Migrator) { if err := migrator.Migrate(); err != nil { log.Fatalln("migrations failed", err.Error()) } }