Improved store migration for RoR 5.
This commit is contained in:
parent
9d7b377652
commit
b258ae24e6
2 changed files with 8 additions and 2 deletions
|
@ -806,7 +806,7 @@ curl http://localhost/api/v1/users/preferences -v -u #{login}:#{password} -H "Co
|
|||
if params[:user]
|
||||
user = User.find(current_user.id)
|
||||
user.with_lock do
|
||||
params[:user].each do |key, value|
|
||||
params[:user].permit!.to_h.each do |key, value|
|
||||
user.preferences[key.to_sym] = value
|
||||
end
|
||||
user.save!
|
||||
|
|
|
@ -15,13 +15,19 @@ class FixedStoreUpgradeRor45 < ActiveRecord::Migration[5.0]
|
|||
end
|
||||
|
||||
Channel.all.each do |channel|
|
||||
channel = Channel.last
|
||||
next if channel.options.blank?
|
||||
channel.options.each do |key, value|
|
||||
channel.options[key] = cleanup(value)
|
||||
end
|
||||
channel.save!
|
||||
end
|
||||
User.with_permissions('ticket.agent').each do |user|
|
||||
next if user.preferences.blank?
|
||||
user.preferences.each do |key, value|
|
||||
user.preferences[key] = cleanup(value)
|
||||
end
|
||||
user.save!
|
||||
end
|
||||
end
|
||||
|
||||
def cleanup(value)
|
||||
|
|
Loading…
Reference in a new issue