2019-04-09 09:30:43 +00:00
|
|
|
class Issue2541FixNotificationEmailWithoutBody < ActiveRecord::Migration[5.1]
|
|
|
|
def up
|
|
|
|
|
|
|
|
# return if it's a new setup
|
|
|
|
return if !Setting.find_by(name: 'system_init_done')
|
|
|
|
|
|
|
|
# update jobs and triggers
|
|
|
|
[::Job, ::Trigger].each do |model|
|
2019-06-13 00:07:09 +00:00
|
|
|
model.where(active: true).each do |record|
|
2019-04-09 09:30:43 +00:00
|
|
|
next if record.perform.blank?
|
|
|
|
|
|
|
|
%w[notification.email notification.sms].each do |action|
|
|
|
|
next if record.perform[action].blank?
|
|
|
|
next if record.perform[action]['body'].present?
|
|
|
|
|
|
|
|
record.perform[action]['body'] = '-'
|
|
|
|
record.save!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# re-enable jobs again
|
|
|
|
scheduler = Scheduler.find_by(method: 'Job.run')
|
|
|
|
return if !scheduler
|
|
|
|
return if scheduler.active?
|
|
|
|
|
|
|
|
scheduler.update!(active: true)
|
|
|
|
end
|
|
|
|
end
|