Fix notification migration

This commit is contained in:
Anton 2023-11-22 13:52:27 +01:00
parent 720eceb59f
commit 203e28dbfe
2 changed files with 10 additions and 1 deletions

View file

@ -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]

View file

@ -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