forked from ebhomengo/niki
1
0
Fork 0
niki/delivery/http_server/end2end/setup/mariadb.go

33 lines
644 B
Go
Raw Normal View History

package setup
import (
"git.gocasts.ir/ebhomengo/niki/repository/migrator"
"git.gocasts.ir/ebhomengo/niki/repository/mysql"
)
func MigrateMariaDB(cfg mysql.Config) func() {
migrations := migrator.New(migrator.Config{
MysqlConfig: cfg,
MigrationPath: "../../../repository/mysql/migration",
MigrationDBName: "gorp_migrations",
})
migrations.Up()
return func() {
migrations.Down()
}
}
func SeedMariaDB(cfg mysql.Config) func() {
seed := migrator.New(migrator.Config{
MysqlConfig: cfg,
MigrationPath: "./setup/seed_data",
MigrationDBName: "test_migrations",
})
seed.Up()
return func() {
seed.Down()
}
}