mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-11 17:00:41 +08:00
Fix notification migration
This commit is contained in:
parent
720eceb59f
commit
203e28dbfe
2 changed files with 10 additions and 1 deletions
|
|
@ -19,7 +19,7 @@ class MigrateNotificationToNoticed < ActiveRecord::Migration[7.0]
|
||||||
5 => 'DeliveryNotification',
|
5 => 'DeliveryNotification',
|
||||||
7 => '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
|
notification = user_notification.notification
|
||||||
|
|
||||||
new_type = type_mapping[notification.type_of]
|
new_type = type_mapping[notification.type_of]
|
||||||
|
|
|
||||||
9
db/migrate/20231122125004_fix_notification_migration.rb
Normal file
9
db/migrate/20231122125004_fix_notification_migration.rb
Normal 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
|
||||||
Loading…
Add table
Reference in a new issue