From 203e28dbfeaf1a00ab373b598eb152d8af1d83be Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 22 Nov 2023 13:52:27 +0100 Subject: [PATCH] Fix notification migration --- .../20231011103114_migrate_notification_to_noticed.rb | 2 +- db/migrate/20231122125004_fix_notification_migration.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20231122125004_fix_notification_migration.rb diff --git a/db/migrate/20231011103114_migrate_notification_to_noticed.rb b/db/migrate/20231011103114_migrate_notification_to_noticed.rb index d7f7706f9..838afee51 100644 --- a/db/migrate/20231011103114_migrate_notification_to_noticed.rb +++ b/db/migrate/20231011103114_migrate_notification_to_noticed.rb @@ -19,7 +19,7 @@ class MigrateNotificationToNoticed < ActiveRecord::Migration[7.0] 5 => 'DeliveryNotification', 7 => 'DeliveryNotification' } - UserNotification.includes(:notification).find_each do |user_notification| + UserNotification.where('created_at > ?', 3.months.ago).includes(:notification).find_each do |user_notification| notification = user_notification.notification new_type = type_mapping[notification.type_of] diff --git a/db/migrate/20231122125004_fix_notification_migration.rb b/db/migrate/20231122125004_fix_notification_migration.rb new file mode 100644 index 000000000..f68ff4583 --- /dev/null +++ b/db/migrate/20231122125004_fix_notification_migration.rb @@ -0,0 +1,9 @@ +class FixNotificationMigration < ActiveRecord::Migration[7.0] + def up + Notification.find_each do |notification| + parsed_params = JSON.parse(notification.params) + parsed_params.delete('_aj_symbol_keys') + notification.update!(params: parsed_params) + end + end +end