mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 22:26:29 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
17 lines
547 B
Ruby
17 lines
547 B
Ruby
# frozen_string_literal: true
|
|
|
|
class FixSeenNotificationIds < ActiveRecord::Migration[4.2]
|
|
def up
|
|
|
|
# There was an error where `seen_notification_id` was being updated incorrectly.
|
|
# This tries to fix some of the bad data.
|
|
execute "UPDATE users SET
|
|
seen_notification_id = COALESCE((SELECT MAX(notifications.id)
|
|
FROM notifications
|
|
WHERE user_id = users.id AND created_at <= users.last_seen_at), 0)"
|
|
end
|
|
|
|
def down
|
|
end
|
|
end
|