[GH-25484] Fix draft removal on post deletion (#25715)
* [GH-25484] Fix draft removal on post deletion * [GH-25484] Add batch migration to remove orphan drafts * [GH-25484] Fix tests of migration and draft store * [GH-25484] Remove translation file changes. * [GH-25484] Remove translation file changes. --------- Co-authored-by: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: Harrison Healey <harrisonmhealey@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
435da9bea7
Коммит
3ac6edb406
@@ -628,6 +628,27 @@ func (s *Server) doDeleteEmptyDraftsMigration(c request.CTX) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) doDeleteOrphanDraftsMigration(c request.CTX) {
|
||||
// If the migration is already marked as completed, don't do it again.
|
||||
if _, err := s.Store().System().GetByName(model.MigrationKeyDeleteOrphanDrafts); err == nil {
|
||||
return
|
||||
}
|
||||
|
||||
jobs, err := s.Store().Job().GetAllByTypeAndStatus(c, model.JobTypeDeleteOrphanDraftsMigration, model.JobStatusPending)
|
||||
if err != nil {
|
||||
mlog.Fatal("failed to get jobs by type and status", mlog.Err(err))
|
||||
return
|
||||
}
|
||||
if len(jobs) > 0 {
|
||||
return
|
||||
}
|
||||
|
||||
if _, appErr := s.Jobs.CreateJobOnce(c, model.JobTypeDeleteOrphanDraftsMigration, nil); appErr != nil {
|
||||
mlog.Fatal("failed to start job for deleting orphan drafts", mlog.Err(appErr))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) DoAppMigrations() {
|
||||
a.Srv().doAppMigrations()
|
||||
}
|
||||
@@ -654,4 +675,5 @@ func (s *Server) doAppMigrations() {
|
||||
s.doElasticsearchFixChannelIndex(c)
|
||||
s.doCloudS3PathMigrations(c)
|
||||
s.doDeleteEmptyDraftsMigration(c)
|
||||
s.doDeleteOrphanDraftsMigration(c)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user