Database connections, refactoring, pokememe parsing in progress
This commit is contained in:
@@ -11,13 +11,17 @@ import (
|
||||
"../config"
|
||||
"../connections"
|
||||
// interfaces
|
||||
"../migrations/migrationsinterface"
|
||||
"../parsers/parsersinterface"
|
||||
"../router/routerinterface"
|
||||
)
|
||||
|
||||
type Context struct {
|
||||
Cfg *config.Config
|
||||
Bot *tgbotapi.BotAPI
|
||||
Migrations migrationsinterface.MigrationsInterface
|
||||
Router routerinterface.RouterInterface
|
||||
Parsers parsersinterface.ParsersInterface
|
||||
Db *sqlx.DB
|
||||
}
|
||||
|
||||
@@ -32,3 +36,17 @@ func (c *Context) RegisterRouterInterface(ri routerinterface.RouterInterface) {
|
||||
c.Router = ri
|
||||
c.Router.Init()
|
||||
}
|
||||
|
||||
func (c *Context) RegisterMigrationsInterface(mi migrationsinterface.MigrationsInterface) {
|
||||
c.Migrations = mi
|
||||
c.Migrations.Init()
|
||||
}
|
||||
|
||||
func (c *Context) RegisterParsersInterface(pi parsersinterface.ParsersInterface) {
|
||||
c.Parsers = pi
|
||||
}
|
||||
|
||||
func (c *Context) RunDatabaseMigrations() {
|
||||
c.Migrations.SetDialect("mysql")
|
||||
c.Migrations.Migrate()
|
||||
}
|
||||
|
Reference in New Issue
Block a user