Beispiel #1
0
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
}
Beispiel #2
0
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
}
Beispiel #3
0
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
}
Beispiel #4
0
// Migrate migrates database
func (a *App) Migrate(migrator gomigrate.Migrator) {
	if err := migrator.Migrate(); err != nil {
		log.Fatalln("migrations failed", err.Error())
	}
}