From 6adc85972a10fcda044f509e000a1618d25bac89 Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Thu, 7 Dec 2023 11:52:30 +0100 Subject: [PATCH] Migrate old user notification settings [SCI-9695] --- ...207092907_migrate_notification_settings.rb | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 db/migrate/20231207092907_migrate_notification_settings.rb diff --git a/db/migrate/20231207092907_migrate_notification_settings.rb b/db/migrate/20231207092907_migrate_notification_settings.rb new file mode 100644 index 000000000..94876a238 --- /dev/null +++ b/db/migrate/20231207092907_migrate_notification_settings.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +class MigrateNotificationSettings < ActiveRecord::Migration[7.0] + def up + User.find_each do |user| + user.settings[:notifications_settings] = + user.settings[:notifications_settings].merge(Extends::DEFAULT_USER_NOTIFICATION_SETTINGS) + + user.settings[:notifications_settings][:project_experiment_access] = { + in_app: user.settings.dig(:notifications_settings, :assignments), + email: user.settings.dig(:notifications_settings, :assignments_email) + } + + user.settings[:notifications_settings][:other_team_invitation] = { + in_app: user.settings.dig(:notifications_settings, :assignments), + email: user.settings.dig(:notifications_settings, :assignments_email) + } + + user.save! + end + end + + def down; end +end