Skip to content

Commit

Permalink
removed remaining singleUser and isPlugin code
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajat-Dabade committed Jul 2, 2024
1 parent c18a26c commit 4950394
Show file tree
Hide file tree
Showing 17 changed files with 52 additions and 635 deletions.
1 change: 0 additions & 1 deletion server/boards/boardsapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func NewBoardsApp(api model.ServicesAPI) (*BoardsApp, error) {
TablePrefix: cfg.DBTablePrefix,
Logger: logger,
DB: sqlDB,
IsPlugin: true,
NewMutexFn: func(name string) (*cluster.Mutex, error) {
return cluster.NewMutex(&mutexAPIAdapter{api: api}, name)
},
Expand Down
7 changes: 3 additions & 4 deletions server/integrationtests/clienttestlib.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ func newTestServerWithLicense(singleUserToken string, licenseType LicenseType) *
if err = logger.Configure("", cfg.LoggingCfgJSON, nil); err != nil {
panic(err)
}
singleUser := len(singleUserToken) > 0
innerStore, err := server.NewStore(cfg, singleUser, logger)
innerStore, err := server.NewStore(cfg, logger)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -199,7 +198,7 @@ func NewTestServerPluginMode() *server.Server {
if err = logger.Configure("", cfg.LoggingCfgJSON, nil); err != nil {
panic(err)
}
innerStore, err := server.NewStore(cfg, false, logger)
innerStore, err := server.NewStore(cfg, logger)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -235,7 +234,7 @@ func newTestServerLocalMode() *server.Server {
panic(err)
}

db, err := server.NewStore(cfg, false, logger)
db, err := server.NewStore(cfg, logger)
if err != nil {
panic(err)
}
Expand Down
4 changes: 1 addition & 3 deletions server/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func New(params Params) (*Server, error) {
return &server, nil
}

func NewStore(config *config.Configuration, isSingleUser bool, logger mlog.LoggerIFace) (store.Store, error) {
func NewStore(config *config.Configuration, logger mlog.LoggerIFace) (store.Store, error) {
sqlDB, err := sql.Open(config.DBType, config.DBConfigString)
if err != nil {
logger.Error("connectDatabase failed", mlog.Err(err))
Expand All @@ -223,8 +223,6 @@ func NewStore(config *config.Configuration, isSingleUser bool, logger mlog.Logge
TablePrefix: config.DBTablePrefix,
Logger: logger,
DB: sqlDB,
IsPlugin: false,
IsSingleUser: isSingleUser,
}

var db store.Store
Expand Down
28 changes: 10 additions & 18 deletions server/services/store/sqlstore/data_migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,18 @@ func (s *SQLStore) RunCategoryUUIDIDMigration() error {
return txErr
}

if s.isPlugin {
if err := s.createCategories(tx); err != nil {
if rollbackErr := tx.Rollback(); rollbackErr != nil {
s.logger.Error("category UUIDs insert categories transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "setSystemSetting"))
}
return err
if err := s.createCategories(tx); err != nil {
if rollbackErr := tx.Rollback(); rollbackErr != nil {
s.logger.Error("category UUIDs insert categories transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "setSystemSetting"))
}
return err
}

if err := s.createCategoryBoards(tx); err != nil {
if rollbackErr := tx.Rollback(); rollbackErr != nil {
s.logger.Error("category UUIDs insert category boards transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "setSystemSetting"))
}
return err
if err := s.createCategoryBoards(tx); err != nil {
if rollbackErr := tx.Rollback(); rollbackErr != nil {
s.logger.Error("category UUIDs insert category boards transaction rollback error", mlog.Err(rollbackErr), mlog.String("methodName", "setSystemSetting"))
}
return err
}

if err := s.setSystemSetting(tx, CategoryUUIDIDMigrationKey, strconv.FormatBool(true)); err != nil {
Expand Down Expand Up @@ -353,9 +351,6 @@ func (s *SQLStore) createCategoryBoards(db sq.BaseRunner) error {
// group messages. This function migrates all boards
// belonging to a DM to the best possible team.
func (s *SQLStore) RunTeamLessBoardsMigration() error {
if !s.isPlugin {
return nil
}

setting, err := s.GetSystemSetting(TeamLessBoardsMigrationKey)
if err != nil {
Expand Down Expand Up @@ -555,9 +550,6 @@ func (s *SQLStore) getBoardUserTeams(tx sq.BaseRunner, board *model.Board) (map[
}

func (s *SQLStore) RunDeletedMembershipBoardsMigration() error {
if !s.isPlugin {
return nil
}

setting, err := s.GetSystemSetting(DeletedMembershipBoardsMigrationKey)
if err != nil {
Expand Down Expand Up @@ -661,7 +653,7 @@ func (s *SQLStore) RunFixCollationsAndCharsetsMigration() error {
var collation string
var charSet string
var err error
if !s.isPlugin || os.Getenv("FOCALBOARD_UNIT_TESTING") == "1" {
if os.Getenv("FOCALBOARD_UNIT_TESTING") == "1" {
collation = "utf8mb4_general_ci"
charSet = "utf8mb4"
} else {
Expand Down
1 change: 0 additions & 1 deletion server/services/store/sqlstore/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func SetupTests(t *testing.T) (store.Store, func()) {
TablePrefix: "test_",
Logger: logger,
DB: sqlDB,
IsPlugin: false,
}
store, err := New(storeParams)
require.NoError(t, err)
Expand Down
32 changes: 14 additions & 18 deletions server/services/store/sqlstore/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,18 @@ func (s *SQLStore) getMigrationConnection() (*sql.DB, error) {
}

func (s *SQLStore) Migrate() error {
if s.isPlugin {
mutex, mutexErr := s.NewMutexFn("Boards_dbMutex")
if mutexErr != nil {
return fmt.Errorf("error creating database mutex: %w", mutexErr)
}

s.logger.Debug("Acquiring cluster lock for Focalboard migrations")
mutex.Lock()
defer func() {
s.logger.Debug("Releasing cluster lock for Focalboard migrations")
mutex.Unlock()
}()
mutex, mutexErr := s.NewMutexFn("Boards_dbMutex")
if mutexErr != nil {
return fmt.Errorf("error creating database mutex: %w", mutexErr)
}

s.logger.Debug("Acquiring cluster lock for Focalboard migrations")
mutex.Lock()
defer func() {
s.logger.Debug("Releasing cluster lock for Focalboard migrations")
mutex.Unlock()
}()

if err := s.EnsureSchemaMigrationFormat(); err != nil {
return err
}
Expand Down Expand Up @@ -148,12 +146,10 @@ func (s *SQLStore) Migrate() error {
}

params := map[string]interface{}{
"prefix": s.tablePrefix,
"postgres": s.dbType == model.PostgresDBType,
"sqlite": s.dbType == model.SqliteDBType,
"mysql": s.dbType == model.MysqlDBType,
"plugin": s.isPlugin,
"singleUser": s.isSingleUser,
"prefix": s.tablePrefix,
"postgres": s.dbType == model.PostgresDBType,
"sqlite": s.dbType == model.SqliteDBType,
"mysql": s.dbType == model.MysqlDBType,
}

migrationAssets := &embedded.AssetSource{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ func (bm *BoardsMigrator) Setup() error {
TablePrefix: tablePrefix,
Logger: logger,
DB: bm.db,
IsPlugin: bm.withMattermostMigrations,
NewMutexFn: func(name string) (*cluster.Mutex, error) {
return nil, fmt.Errorf("not implemented")
},
Expand Down
18 changes: 8 additions & 10 deletions server/services/store/sqlstore/migrationstests/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import (
)

type TestHelper struct {
t *testing.T
f *foundation.Foundation
isPlugin bool
t *testing.T
f *foundation.Foundation
}

func (th *TestHelper) IsPostgres() bool {
Expand All @@ -33,20 +32,19 @@ func SetupPluginTestHelper(t *testing.T) (*TestHelper, func()) {
t.Skip("Skipping plugin mode test for SQLite")
}

return setupTestHelper(t, true)
return setupTestHelper(t)
}

func SetupTestHelper(t *testing.T) (*TestHelper, func()) {
return setupTestHelper(t, false)
return setupTestHelper(t)
}

func setupTestHelper(t *testing.T, isPlugin bool) (*TestHelper, func()) {
f := foundation.New(t, NewBoardsMigrator(isPlugin))
func setupTestHelper(t *testing.T) (*TestHelper, func()) {
f := foundation.New(t, NewBoardsMigrator(true))

th := &TestHelper{
t: t,
f: f,
isPlugin: isPlugin,
t: t,
f: f,
}

tearDown := func() {
Expand Down
4 changes: 1 addition & 3 deletions server/services/store/sqlstore/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ type Params struct {
TablePrefix string
Logger mlog.LoggerIFace
DB *sql.DB
IsPlugin bool
IsSingleUser bool
NewMutexFn MutexFactory
ServicesAPI servicesAPI
SkipMigrations bool
ConfigFn func() *mmModel.Config
}

func (p Params) CheckValid() error {
if p.IsPlugin && p.NewMutexFn == nil {
if p.NewMutexFn == nil {
return ErrStoreParam{name: "NewMutexFn", issue: "cannot be nil in plugin mode"}
}
return nil
Expand Down
4 changes: 0 additions & 4 deletions server/services/store/sqlstore/sqlstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ type SQLStore struct {
tablePrefix string
connectionString string
dbPingAttempts int
isPlugin bool
isSingleUser bool
logger mlog.LoggerIFace
NewMutexFn MutexFactory
servicesAPI servicesAPI
Expand Down Expand Up @@ -51,8 +49,6 @@ func New(params Params) (*SQLStore, error) {
tablePrefix: params.TablePrefix,
connectionString: params.ConnectionString,
logger: params.Logger,
isPlugin: params.IsPlugin,
isSingleUser: params.IsSingleUser,
NewMutexFn: params.NewMutexFn,
servicesAPI: params.ServicesAPI,
configFn: params.ConfigFn,
Expand Down
73 changes: 0 additions & 73 deletions webapp/src/pages/changePasswordPage.scss

This file was deleted.

Loading

0 comments on commit 4950394

Please sign in to comment.