Remove code duplication and move utility methods to the store utils (#20091)

* Remove code duplication and move utility methods to the store utils

* Fix typo
Этот коммит содержится в:
Miguel de la Cruz
2022-04-29 12:15:38 +02:00
коммит произвёл GitHub
родитель 79a0d3dac4
Коммит c076f9fdf9
6 изменённых файлов: 60 добавлений и 98 удалений

Просмотреть файл

@@ -10,7 +10,6 @@ import (
"reflect"
"strings"
"github.com/go-sql-driver/mysql"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/i18n"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
@@ -262,29 +261,3 @@ func equal(oldCfg, newCfg *model.Config) (bool, error) {
}
return !bytes.Equal(oldCfgBytes, newCfgBytes), nil
}
// appendMultipleStatementsFlag attached dsn parameters to MySQL dsn in order to make migrations work.
func appendMultipleStatementsFlag(dataSource string) (string, error) {
config, err := mysql.ParseDSN(dataSource)
if err != nil {
return "", err
}
if config.Params == nil {
config.Params = map[string]string{}
}
config.Params["multiStatements"] = "true"
return config.FormatDSN(), nil
}
// resetReadTimeout removes the timeout contraint from the MySQL dsn.
func resetReadTimeout(dataSource string) (string, error) {
config, err := mysql.ParseDSN(dataSource)
if err != nil {
return "", err
}
config.ReadTimeout = 0
return config.FormatDSN(), nil
}