From be64f5f0e761fa0fb36c33d39dfc818a9558a854 Mon Sep 17 00:00:00 2001 From: Essem Date: Sun, 29 Dec 2024 00:06:41 -0600 Subject: [PATCH] Fix old migration --- db/migrate/20230215074425_move_emoji_reaction_settings.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/db/migrate/20230215074425_move_emoji_reaction_settings.rb b/db/migrate/20230215074425_move_emoji_reaction_settings.rb index 6d2d5e167ad9ca..789097117f7fb0 100644 --- a/db/migrate/20230215074425_move_emoji_reaction_settings.rb +++ b/db/migrate/20230215074425_move_emoji_reaction_settings.rb @@ -7,21 +7,19 @@ class User < ApplicationRecord; end 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) || {}