MM-44638: Remove upgrade.go (#20309)
We remove any remaining migrations from the upgrade.go file ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c92cbb606a
Коммит
ec0284b459
@@ -18,6 +18,7 @@ const SystemConsoleRolesCreationMigrationKey = "SystemConsoleRolesCreationMigrat
|
||||
const ContentExtractionConfigDefaultTrueMigrationKey = "ContentExtractionConfigDefaultTrueMigrationComplete"
|
||||
const PlaybookRolesCreationMigrationKey = "PlaybookRolesCreationMigrationComplete"
|
||||
const FirstAdminSetupCompleteKey = model.SystemFirstAdminSetupComplete
|
||||
const remainingSchemaMigrationsKey = "RemainingSchemaMigrations"
|
||||
|
||||
// This function migrates the default built in roles from code/config to the database.
|
||||
func (a *App) DoAdvancedPermissionsMigration() {
|
||||
@@ -479,6 +480,33 @@ func (s *Server) doFirstAdminSetupCompleteMigration() {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) doRemainingSchemaMigrations() {
|
||||
// If the migration is already marked as completed, don't do it again.
|
||||
if _, err := s.Store.System().GetByName(remainingSchemaMigrationsKey); err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if teams, err := s.Store.Team().GetByEmptyInviteID(); err != nil {
|
||||
mlog.Error("Error fetching Teams without InviteID", mlog.Err(err))
|
||||
} else {
|
||||
for _, team := range teams {
|
||||
team.InviteId = model.NewId()
|
||||
if _, err := s.Store.Team().Update(team); err != nil {
|
||||
mlog.Error("Error updating Team InviteIDs", mlog.String("team_id", team.Id), mlog.Err(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
system := model.System{
|
||||
Name: remainingSchemaMigrationsKey,
|
||||
Value: "true",
|
||||
}
|
||||
|
||||
if err := s.Store.System().Save(&system); err != nil {
|
||||
mlog.Critical("Failed to mark the remaining schema migrations as completed.", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) DoAppMigrations() {
|
||||
a.Srv().doAppMigrations()
|
||||
}
|
||||
@@ -497,4 +525,5 @@ func (s *Server) doAppMigrations() {
|
||||
s.doContentExtractionConfigDefaultTrueMigration()
|
||||
s.doPlaybooksRolesCreationMigration()
|
||||
s.doFirstAdminSetupCompleteMigration()
|
||||
s.doRemainingSchemaMigrations()
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user