1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-02-01 19:14:35 +02:00

services/store: use mattermost sql settings for migration connections (#4395)

* services/store: use mattermost sql settings for migration connections

* fix db type issue
This commit is contained in:
Ibrahim Serdar Acikgoz 2022-12-23 19:19:37 +03:00 committed by GitHub
parent 9ef5c5186b
commit 8585ff04d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 6 deletions

View File

@ -84,6 +84,7 @@ func NewBoardsApp(api model.ServicesAPI) (*BoardsApp, error) {
return cluster.NewMutex(&mutexAPIAdapter{api: api}, name)
},
ServicesAPI: api,
ConfigFn: api.GetConfig,
}
var db store.Store

View File

@ -13,6 +13,7 @@ import (
sq "github.com/Masterminds/squirrel"
mmModel "github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
"github.com/mattermost/mattermost-server/v6/store/sqlstore"
@ -59,14 +60,14 @@ func (s *SQLStore) getMigrationConnection() (*sql.DB, error) {
}
}
db, err := sql.Open(s.dbType, connectionString)
if err != nil {
return nil, err
var settings mmModel.SqlSettings
settings.SetDefaults(false)
if s.configFn != nil {
settings = s.configFn().SqlSettings
}
*settings.DriverName = s.dbType
if err = db.Ping(); err != nil {
return nil, err
}
db := sqlstore.SetupConnection("master", connectionString, &settings)
return db, nil
}

View File

@ -26,6 +26,7 @@ type Params struct {
NewMutexFn MutexFactory
ServicesAPI servicesAPI
SkipMigrations bool
ConfigFn func() *mmModel.Config
}
func (p Params) CheckValid() error {

View File

@ -29,6 +29,7 @@ type SQLStore struct {
servicesAPI servicesAPI
isBinaryParam bool
schemaName string
configFn func() *mmModel.Config
}
// MutexFactory is used by the store in plugin mode to generate
@ -53,6 +54,7 @@ func New(params Params) (*SQLStore, error) {
isSingleUser: params.IsSingleUser,
NewMutexFn: params.NewMutexFn,
servicesAPI: params.ServicesAPI,
configFn: params.ConfigFn,
}
var err error