MM-35030: Hoist GetDBVersion before creating store (#17764)
* MM-35030: Hoist GetDBVersion before creating store The creation of the store included running the migrations which means that SQL statements would be executed before we could make the check for DB version. We perform the DB check before running the migrations. https://mattermost.atlassian.net/browse/MM-35030 ```release-note NONE ``` * fix lint error
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3daa315028
Коммит
723902f4cb
@@ -20,7 +20,6 @@ import (
|
||||
"os/exec"
|
||||
"path"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@@ -360,19 +359,6 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
if s.newStore == nil {
|
||||
s.newStore = func() (store.Store, error) {
|
||||
s.sqlStore = sqlstore.New(s.Config().SqlSettings, s.Metrics)
|
||||
if s.sqlStore.DriverName() == model.DATABASE_DRIVER_POSTGRES {
|
||||
ver, err2 := s.sqlStore.GetDbVersion(true)
|
||||
if err2 != nil {
|
||||
return nil, errors.Wrap(err2, "cannot get DB version")
|
||||
}
|
||||
intVer, err2 := strconv.Atoi(ver)
|
||||
if err2 != nil {
|
||||
return nil, errors.Wrap(err2, "cannot parse DB version")
|
||||
}
|
||||
if intVer < sqlstore.MinimumRequiredPostgresVersion {
|
||||
return nil, fmt.Errorf("minimum required postgres version is %s; found %s", sqlstore.VersionString(sqlstore.MinimumRequiredPostgresVersion), sqlstore.VersionString(intVer))
|
||||
}
|
||||
}
|
||||
|
||||
lcl, err2 := localcachelayer.NewLocalCacheLayer(
|
||||
retrylayer.New(s.sqlStore),
|
||||
|
||||
Ссылка в новой задаче
Block a user