mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: ensure rebaking works even when some users have inconsistent data (#30261)
* DEV: add db consistency check for UserEmail * DEV: add db consistency check for UserAvatar * DEV: ignore inconsistent data related to user avatars when deciding whether to rebake old posts Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com> --------- Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
This commit is contained in:
@@ -152,6 +152,13 @@ class UserAvatar < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def self.ensure_consistency!(max_optimized_avatars_to_remove: 20_000)
|
||||
DB.exec <<~SQL
|
||||
DELETE FROM user_avatars
|
||||
USING user_avatars ua
|
||||
LEFT JOIN users u ON ua.user_id = u.id
|
||||
WHERE user_avatars.id = ua.id AND u.id IS NULL
|
||||
SQL
|
||||
|
||||
DB.exec <<~SQL
|
||||
UPDATE user_avatars
|
||||
SET gravatar_upload_id = NULL
|
||||
|
||||
Reference in New Issue
Block a user