MM-43770: Rename to Threads.ThreadDeleteAt (#20074)
Old versions of the Mattermost server did not qualify queries scanning both `Posts` and `Threads`, and choke on the ambiguity in deciding between the new `DeleteAt` on `Threads` and the `DeleteAt` on `Posts` in existing queries. While this problem is transient only while running multiple server versions, it effectively makes our backwards compatibility guarantee void, not to mention complicating cloud deployments. Work around this by renaming `Threads.DeleteAt` to `Threads.ThreadDeleteAt`. The old migration is nulled out, but remains, since some test servers have already upgraded and manually fixing each affected instance would be problematic. Thew new migration takes care of removing the old column -- if it ever existed. Fixes: https://mattermost.atlassian.net/browse/MM-43770 Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2474b40cb9
Коммит
72a5d99ae3
@@ -2605,7 +2605,7 @@ func (s *SqlPostStore) permanentDeleteThreads(transaction *sqlxTxWrapper, postId
|
||||
func (s *SqlPostStore) deleteThread(transaction *sqlxTxWrapper, postId string, deleteAtTime int64) error {
|
||||
queryString, args, err := s.getQueryBuilder().
|
||||
Update("Threads").
|
||||
Set("DeleteAt", deleteAtTime).
|
||||
Set("ThreadDeleteAt", deleteAtTime).
|
||||
Where(sq.Eq{"PostId": postId}).
|
||||
ToSql()
|
||||
if err != nil {
|
||||
@@ -2701,7 +2701,7 @@ func (s *SqlPostStore) updateThreadsFromPosts(transaction *sqlxTxWrapper, posts
|
||||
"Threads.ReplyCount",
|
||||
"Threads.LastReplyAt",
|
||||
"Threads.Participants",
|
||||
"COALESCE(Threads.DeleteAt, 0) AS DeleteAt",
|
||||
"COALESCE(Threads.ThreadDeleteAt, 0) AS DeleteAt",
|
||||
).
|
||||
From("Threads").
|
||||
Where(sq.Eq{"Threads.PostId": rootIds}).
|
||||
|
||||
@@ -50,7 +50,7 @@ func (s *SqlThreadStore) initializeQueries() {
|
||||
"Threads.ReplyCount",
|
||||
"Threads.LastReplyAt",
|
||||
"Threads.Participants",
|
||||
"COALESCE(Threads.DeleteAt, 0) AS DeleteAt",
|
||||
"COALESCE(Threads.ThreadDeleteAt, 0) AS DeleteAt",
|
||||
).
|
||||
From("Threads")
|
||||
|
||||
@@ -61,7 +61,7 @@ func (s *SqlThreadStore) initializeQueries() {
|
||||
"Threads.ReplyCount",
|
||||
"Threads.LastReplyAt",
|
||||
"Threads.Participants",
|
||||
"COALESCE(Threads.DeleteAt, 0) AS ThreadDeleteAt",
|
||||
"COALESCE(Threads.ThreadDeleteAt, 0) AS ThreadDeleteAt",
|
||||
).
|
||||
From("Threads")
|
||||
}
|
||||
@@ -107,7 +107,7 @@ func (s *SqlThreadStore) getTotalThreadsQuery(userId, teamId string, opts model.
|
||||
}
|
||||
|
||||
if !opts.Deleted {
|
||||
query = query.Where(sq.Eq{"COALESCE(Threads.DeleteAt, 0)": 0})
|
||||
query = query.Where(sq.Eq{"COALESCE(Threads.ThreadDeleteAt, 0)": 0})
|
||||
}
|
||||
|
||||
return query
|
||||
@@ -180,7 +180,7 @@ func (s *SqlThreadStore) GetTotalUnreadMentions(userId, teamId string, opts mode
|
||||
}
|
||||
|
||||
if !opts.Deleted {
|
||||
query = query.Where(sq.Eq{"COALESCE(Threads.DeleteAt, 0)": 0})
|
||||
query = query.Where(sq.Eq{"COALESCE(Threads.ThreadDeleteAt, 0)": 0})
|
||||
}
|
||||
|
||||
sql, args, err := query.ToSql()
|
||||
@@ -256,8 +256,8 @@ func (s *SqlThreadStore) GetThreadsForUser(userId, teamId string, opts model.Get
|
||||
|
||||
if !opts.Deleted {
|
||||
query = query.Where(sq.Or{
|
||||
sq.Eq{"Threads.DeleteAt": nil},
|
||||
sq.Eq{"Threads.DeleteAt": 0},
|
||||
sq.Eq{"Threads.ThreadDeleteAt": nil},
|
||||
sq.Eq{"Threads.ThreadDeleteAt": 0},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ func (s *SqlThreadStore) GetTeamsUnreadForUser(userID string, teamIDs []string)
|
||||
sq.Eq{"ThreadMemberships.UserId": userID},
|
||||
sq.Eq{"ThreadMemberships.Following": true},
|
||||
sq.Eq{"Channels.TeamId": teamIDs},
|
||||
sq.Eq{"COALESCE(Threads.DeleteAt, 0)": 0},
|
||||
sq.Eq{"COALESCE(Threads.ThreadDeleteAt, 0)": 0},
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
Ссылка в новой задаче
Block a user