fastpastebin/database/migrations/exported.go

32 lines
562 B
Go
Raw Normal View History

2018-04-30 18:42:17 +05:00
package migrations
import (
// local
"github.com/pztrn/fastpastebin/context"
// other
//"github.com/jmoiron/sqlx"
"github.com/pressly/goose"
)
var (
c *context.Context
)
func New(cc *context.Context) {
c = cc
}
func Migrate() {
c.Logger.Info().Msg("Migrating database...")
goose.SetDialect("mysql")
goose.AddNamedMigration("1_initial.go", InitialUp, nil)
dbConn := c.Database.GetDatabaseConnection()
err := goose.Up(dbConn.DB, ".")
if err != nil {
c.Logger.Panic().Msgf("Failed to migrate database to latest version: %s", err.Error())
}
}