forked from ebhomengo/niki
33 lines
644 B
Go
33 lines
644 B
Go
|
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()
|
||
|
}
|
||
|
}
|