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