mirror of
https://github.com/glitch-soc/mastodon
synced 2025-04-24 20:04:51 +00:00
Fix old migration
This commit is contained in:
parent
ddac944404
commit
470459c9b8
1 changed files with 3 additions and 5 deletions
|
@ -7,21 +7,19 @@ class MoveEmojiReactionSettings < ActiveRecord::Migration[6.1]
|
|||
setting_visible_reactions: 'visible_reactions',
|
||||
}.freeze
|
||||
|
||||
class LegacySetting < ApplicationRecord
|
||||
self.table_name = 'settings'
|
||||
|
||||
class Setting < ApplicationRecord
|
||||
def var
|
||||
self[:var]&.to_sym
|
||||
end
|
||||
|
||||
def value
|
||||
YAML.safe_load(self[:value], permitted_classes: [ActiveSupport::HashWithIndifferentAccess]) if self[:value].present?
|
||||
YAML.safe_load(self[:value], permitted_classes: [ActiveSupport::HashWithIndifferentAccess, Symbol]) if self[:value].present?
|
||||
end
|
||||
end
|
||||
|
||||
def up
|
||||
User.find_in_batches do |users|
|
||||
previous_settings_for_batch = LegacySetting.where(thing_type: 'User', thing_id: users.map(&:id)).group_by(&:thing_id)
|
||||
previous_settings_for_batch = Setting.where(thing_type: 'User', thing_id: users.map(&:id)).group_by(&:thing_id)
|
||||
|
||||
users.each do |user|
|
||||
previous_settings = previous_settings_for_batch[user.id]&.index_by(&:var) || {}
|
||||
|
|
Loading…
Add table
Reference in a new issue