mirror of
https://github.com/mattermost/focalboard.git
synced 2025-04-23 11:48:54 +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:
parent
9ef5c5186b
commit
8585ff04d2
@ -84,6 +84,7 @@ func NewBoardsApp(api model.ServicesAPI) (*BoardsApp, error) {
|
|||||||
return cluster.NewMutex(&mutexAPIAdapter{api: api}, name)
|
return cluster.NewMutex(&mutexAPIAdapter{api: api}, name)
|
||||||
},
|
},
|
||||||
ServicesAPI: api,
|
ServicesAPI: api,
|
||||||
|
ConfigFn: api.GetConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
var db store.Store
|
var db store.Store
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
|
|
||||||
sq "github.com/Masterminds/squirrel"
|
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/shared/mlog"
|
||||||
"github.com/mattermost/mattermost-server/v6/store/sqlstore"
|
"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)
|
var settings mmModel.SqlSettings
|
||||||
if err != nil {
|
settings.SetDefaults(false)
|
||||||
return nil, err
|
if s.configFn != nil {
|
||||||
|
settings = s.configFn().SqlSettings
|
||||||
}
|
}
|
||||||
|
*settings.DriverName = s.dbType
|
||||||
|
|
||||||
if err = db.Ping(); err != nil {
|
db := sqlstore.SetupConnection("master", connectionString, &settings)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return db, nil
|
return db, nil
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ type Params struct {
|
|||||||
NewMutexFn MutexFactory
|
NewMutexFn MutexFactory
|
||||||
ServicesAPI servicesAPI
|
ServicesAPI servicesAPI
|
||||||
SkipMigrations bool
|
SkipMigrations bool
|
||||||
|
ConfigFn func() *mmModel.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Params) CheckValid() error {
|
func (p Params) CheckValid() error {
|
||||||
|
@ -29,6 +29,7 @@ type SQLStore struct {
|
|||||||
servicesAPI servicesAPI
|
servicesAPI servicesAPI
|
||||||
isBinaryParam bool
|
isBinaryParam bool
|
||||||
schemaName string
|
schemaName string
|
||||||
|
configFn func() *mmModel.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
// MutexFactory is used by the store in plugin mode to generate
|
// MutexFactory is used by the store in plugin mode to generate
|
||||||
@ -53,6 +54,7 @@ func New(params Params) (*SQLStore, error) {
|
|||||||
isSingleUser: params.IsSingleUser,
|
isSingleUser: params.IsSingleUser,
|
||||||
NewMutexFn: params.NewMutexFn,
|
NewMutexFn: params.NewMutexFn,
|
||||||
servicesAPI: params.ServicesAPI,
|
servicesAPI: params.ServicesAPI,
|
||||||
|
configFn: params.ConfigFn,
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
Loading…
x
Reference in New Issue
Block a user