Database dialects, proper database shutdown, pagination in configuration.

Added possibility to use different database (storage) backends. Currently
supported: flatfiles and mysql. Fixes #2.

Added database shutdown call. This call will properly shutdown database
connections (in case of RDBMS) or flush pastes index cache on disk (in
case of flatfiles).

De-hardcoded pagination count. Fixes #12.
This commit is contained in:
2018-05-27 12:25:01 +05:00
parent 296e2771d6
commit 0cca0f453f
22 changed files with 854 additions and 175 deletions

View File

@@ -54,8 +54,12 @@ func Migrate() {
// Add new migrations BEFORE this message.
dbConn := c.Database.GetDatabaseConnection()
err := goose.Up(dbConn.DB, ".")
if err != nil {
c.Logger.Panic().Msgf("Failed to migrate database to latest version: %s", err.Error())
if dbConn != nil {
err := goose.Up(dbConn, ".")
if err != nil {
c.Logger.Panic().Msgf("Failed to migrate database to latest version: %s", err.Error())
}
} else {
c.Logger.Warn().Msg("Current database dialect isn't supporting migrations, skipping")
}
}