mirror of
https://github.com/glitch-soc/mastodon
synced 2025-04-24 17:44:50 +00:00
Remove emoji reaction settings move migration
It's now broken and pointless due to the complete removal of legacy user settings. Since this effectively predates the current reaction branch as well, there is little chance that someone running an older iteration will need to use this migration.
This commit is contained in:
parent
470459c9b8
commit
6ceb161a37
1 changed files with 0 additions and 47 deletions
|
@ -1,47 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MoveEmojiReactionSettings < ActiveRecord::Migration[6.1]
|
||||
class User < ApplicationRecord; end
|
||||
|
||||
MAPPING = {
|
||||
setting_visible_reactions: 'visible_reactions',
|
||||
}.freeze
|
||||
|
||||
class Setting < ApplicationRecord
|
||||
def var
|
||||
self[:var]&.to_sym
|
||||
end
|
||||
|
||||
def value
|
||||
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 = 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) || {}
|
||||
user_settings = Oj.load(user.settings || '{}')
|
||||
user_settings.delete('theme')
|
||||
|
||||
MAPPING.each do |legacy_key, new_key|
|
||||
value = previous_settings[legacy_key]&.value
|
||||
|
||||
next if value.blank?
|
||||
|
||||
if value.is_a?(Hash)
|
||||
value.each do |nested_key, nested_value|
|
||||
user_settings[MAPPING[legacy_key][nested_key.to_sym]] = nested_value
|
||||
end
|
||||
else
|
||||
user_settings[new_key] = value
|
||||
end
|
||||
end
|
||||
|
||||
user.update_column('settings', Oj.dump(user_settings))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue