mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 06:48:47 +08:00
FIX: Stop updating bookmarked column from TopicUser.update_post_action_cache (#10188)
* This is causing issues where sometimes bookmarked is out of sync with what is in the Bookmark table. The BookmarkManager handles updating this column now. * Add migration to fix bookmarked column that is incorrectly marked false when a Bookmark record exists.
This commit is contained in:
@ -0,0 +1,20 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class FixTopicUserBookmarkedSyncIssues < ActiveRecord::Migration[6.0]
|
||||
def up
|
||||
sql = <<~SQL
|
||||
UPDATE topic_users SET bookmarked = true WHERE id IN (
|
||||
SELECT topic_users.id
|
||||
FROM topic_users
|
||||
INNER JOIN bookmarks ON bookmarks.user_id = topic_users.user_id AND
|
||||
bookmarks.topic_id = topic_users.topic_id
|
||||
WHERE NOT topic_users.bookmarked
|
||||
) AND NOT bookmarked
|
||||
SQL
|
||||
DB.exec(sql)
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user