Improved store migration for RoR 5.

This commit is contained in:
Martin Edenhofer 2017-10-23 04:35:38 +02:00
parent 9d7b377652
commit b258ae24e6
2 changed files with 8 additions and 2 deletions

View file

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

View file

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