Moved database migrations for MySQL dialect into approriate package.

This commit is contained in:
Stanislav Nikitin 2018-12-01 02:29:14 +05:00
parent 400ce0db0c
commit b6556d6e90
7 changed files with 5 additions and 3 deletions

View File

@ -35,7 +35,6 @@ import (
"gitlab.com/pztrn/fastpastebin/captcha" "gitlab.com/pztrn/fastpastebin/captcha"
"gitlab.com/pztrn/fastpastebin/context" "gitlab.com/pztrn/fastpastebin/context"
"gitlab.com/pztrn/fastpastebin/database" "gitlab.com/pztrn/fastpastebin/database"
"gitlab.com/pztrn/fastpastebin/database/migrations"
"gitlab.com/pztrn/fastpastebin/pastes" "gitlab.com/pztrn/fastpastebin/pastes"
"gitlab.com/pztrn/fastpastebin/templater" "gitlab.com/pztrn/fastpastebin/templater"
) )
@ -56,8 +55,6 @@ func main() {
c.LoadConfiguration() c.LoadConfiguration()
database.New(c) database.New(c)
c.Database.Initialize() c.Database.Initialize()
migrations.New(c)
migrations.Migrate()
templater.Initialize(c) templater.Initialize(c)
api.New(c) api.New(c)
api.InitializeAPI() api.InitializeAPI()

View File

@ -30,6 +30,7 @@ import (
"fmt" "fmt"
// local // local
"gitlab.com/pztrn/fastpastebin/database/dialects/mysql/migrations"
"gitlab.com/pztrn/fastpastebin/pastes/model" "gitlab.com/pztrn/fastpastebin/pastes/model"
// other // other
@ -145,6 +146,10 @@ func (db *Database) Initialize() {
c.Logger.Info().Msg("Database connection established") c.Logger.Info().Msg("Database connection established")
db.db = dbConn db.db = dbConn
// Perform migrations.
migrations.New(c)
migrations.Migrate()
} }
func (db *Database) SavePaste(p *pastesmodel.Paste) (int64, error) { func (db *Database) SavePaste(p *pastesmodel.Paste) (int64, error) {