trabajo-afectivo/db/migrate/20170113000002_slack_group_config_issue_587.rb

21 lines
562 B
Ruby
Raw Normal View History

class SlackGroupConfigIssue587 < ActiveRecord::Migration
def up
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
setting = Setting.find_by(name: 'slack_config')
return if !setting
return if !setting.state_current['value']
return if !setting.state_current['value']['items']
config_item = setting.state_current['value']['items'].first
return if !config_item
return if !config_item.key?('group_id')
config_item['group_ids'] = config_item.delete('group_id')
setting.save!
end
end