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/migrations",
		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()
	}
}
