1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-06-06 23:46:29 +02:00

23 lines
627 B
Go
Raw Normal View History

package schema
import (
"log"
"github.com/geeks-accelerator/sqlxmigrate"
"github.com/jmoiron/sqlx"
)
2019-08-01 16:17:47 -08:00
func Migrate(masterDb *sqlx.DB, log *log.Logger, isUnittest bool) error {
// Load list of Schema migrations and init new sqlxmigrate client
2019-08-01 16:17:47 -08:00
migrations := migrationList(masterDb, log, isUnittest)
m := sqlxmigrate.New(masterDb, sqlxmigrate.DefaultOptions, migrations)
m.SetLogger(log)
// Append any schema that need to be applied if this is a fresh migration
// ie. the migrations database table does not exist.
2019-08-01 16:17:47 -08:00
m.InitSchema(initSchema(masterDb, log, isUnittest))
// Execute the migrations
return m.Migrate()
}