Migrates Channel.ResetAllChannelSchemes to sync by default (#11275)
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
41e5ec3c5e
Коммит
a760f32526
@@ -23,8 +23,8 @@ func (a *App) ResetPermissionsSystem() *model.AppError {
|
||||
}
|
||||
|
||||
// Reset all Channels to not have a scheme.
|
||||
if result := <-a.Srv.Store.Channel().ResetAllChannelSchemes(); result.Err != nil {
|
||||
return result.Err
|
||||
if err := a.Srv.Store.Channel().ResetAllChannelSchemes(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Reset all Custom Role assignments to Users.
|
||||
|
||||
@@ -2340,36 +2340,31 @@ func (s SqlChannelStore) MigrateChannelMembers(fromChannelId string, fromUserId
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) ResetAllChannelSchemes() store.StoreChannel {
|
||||
return store.Do(func(result *store.StoreResult) {
|
||||
transaction, err := s.GetMaster().Begin()
|
||||
if err != nil {
|
||||
result.Err = model.NewAppError("SqlChannelStore.ResetAllChannelSchemes", "store.sql_channel.reset_all_channel_schemes.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
defer finalizeTransaction(transaction)
|
||||
func (s SqlChannelStore) ResetAllChannelSchemes() *model.AppError {
|
||||
transaction, err := s.GetMaster().Begin()
|
||||
if err != nil {
|
||||
return model.NewAppError("SqlChannelStore.ResetAllChannelSchemes", "store.sql_channel.reset_all_channel_schemes.open_transaction.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
defer finalizeTransaction(transaction)
|
||||
|
||||
*result = s.resetAllChannelSchemesT(transaction)
|
||||
if result.Err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err := transaction.Commit(); err != nil {
|
||||
result.Err = model.NewAppError("SqlChannelStore.ResetAllChannelSchemes", "store.sql_channel.reset_all_channel_schemes.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) resetAllChannelSchemesT(transaction *gorp.Transaction) store.StoreResult {
|
||||
result := store.StoreResult{}
|
||||
|
||||
if _, err := transaction.Exec("UPDATE Channels SET SchemeId=''"); err != nil {
|
||||
result.Err = model.NewAppError("SqlChannelStore.ResetAllChannelSchemes", "store.sql_channel.reset_all_channel_schemes.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
return result
|
||||
resetErr := s.resetAllChannelSchemesT(transaction)
|
||||
if resetErr != nil {
|
||||
return resetErr
|
||||
}
|
||||
|
||||
return result
|
||||
if err := transaction.Commit(); err != nil {
|
||||
return model.NewAppError("SqlChannelStore.ResetAllChannelSchemes", "store.sql_channel.reset_all_channel_schemes.commit_transaction.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) resetAllChannelSchemesT(transaction *gorp.Transaction) *model.AppError {
|
||||
if _, err := transaction.Exec("UPDATE Channels SET SchemeId=''"); err != nil {
|
||||
return model.NewAppError("SqlChannelStore.ResetAllChannelSchemes", "store.sql_channel.reset_all_channel_schemes.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s SqlChannelStore) ClearAllCustomRoleAssignments() *model.AppError {
|
||||
|
||||
@@ -191,7 +191,7 @@ type ChannelStore interface {
|
||||
ClearCaches()
|
||||
GetChannelsByScheme(schemeId string, offset int, limit int) StoreChannel
|
||||
MigrateChannelMembers(fromChannelId string, fromUserId string) (map[string]string, *model.AppError)
|
||||
ResetAllChannelSchemes() StoreChannel
|
||||
ResetAllChannelSchemes() *model.AppError
|
||||
ClearAllCustomRoleAssignments() *model.AppError
|
||||
MigratePublicChannels() error
|
||||
GetAllChannelsForExportAfter(limit int, afterId string) ([]*model.ChannelForExport, *model.AppError)
|
||||
|
||||
@@ -3037,8 +3037,8 @@ func testResetAllChannelSchemes(t *testing.T, ss store.Store) {
|
||||
assert.Equal(t, s1.Id, *c1.SchemeId)
|
||||
assert.Equal(t, s1.Id, *c2.SchemeId)
|
||||
|
||||
res := <-ss.Channel().ResetAllChannelSchemes()
|
||||
assert.Nil(t, res.Err)
|
||||
err := ss.Channel().ResetAllChannelSchemes()
|
||||
assert.Nil(t, err)
|
||||
|
||||
c1, _ = ss.Channel().Get(c1.Id, true)
|
||||
c2, _ = ss.Channel().Get(c2.Id, true)
|
||||
|
||||
@@ -1161,15 +1161,15 @@ func (_m *ChannelStore) RemoveMember(channelId string, userId string) *model.App
|
||||
}
|
||||
|
||||
// ResetAllChannelSchemes provides a mock function with given fields:
|
||||
func (_m *ChannelStore) ResetAllChannelSchemes() store.StoreChannel {
|
||||
func (_m *ChannelStore) ResetAllChannelSchemes() *model.AppError {
|
||||
ret := _m.Called()
|
||||
|
||||
var r0 store.StoreChannel
|
||||
if rf, ok := ret.Get(0).(func() store.StoreChannel); ok {
|
||||
var r0 *model.AppError
|
||||
if rf, ok := ret.Get(0).(func() *model.AppError); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(store.StoreChannel)
|
||||
r0 = ret.Get(0).(*model.AppError)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user