MM-31356: Add a minimum required version check for Postgres (#16597)
* MM-31356: Add a minimum required version check for Postgres To keep conformance with our failing fast and obvious philosophy, we add a check to prevent Mattermost server from starting if the postgres version is below 10.0. This gives customers a chance to upgrade their database before upgrading their Mattermost version, than to run into weird compatibility issues after they have finished the upgrade. https://mattermost.atlassian.net/browse/MM-31356 ```release-note NONE ``` * fix lint errors * Use a function to pretty-print version string * rectify comment
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
83afd756b6
Коммит
c54b262351
@@ -16,6 +16,7 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@@ -319,6 +320,19 @@ 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.MINIMUM_REQUIRED_POSTGRES_VERSION {
|
||||
return nil, fmt.Errorf("minimum required postgres version is %s; found %s", sqlstore.VersionString(sqlstore.MINIMUM_REQUIRED_POSTGRES_VERSION), sqlstore.VersionString(intVer))
|
||||
}
|
||||
}
|
||||
|
||||
lcl, err2 := localcachelayer.NewLocalCacheLayer(
|
||||
retrylayer.New(s.sqlStore),
|
||||
|
||||
Ссылка в новой задаче
Block a user