20170113000002_slack_group_config_issue_587.rb 562 B

1234567891011121314151617181920
  1. class SlackGroupConfigIssue587 < ActiveRecord::Migration
  2. def up
  3. # return if it's a new setup
  4. return if !Setting.find_by(name: 'system_init_done')
  5. setting = Setting.find_by(name: 'slack_config')
  6. return if !setting
  7. return if !setting.state_current['value']
  8. return if !setting.state_current['value']['items']
  9. config_item = setting.state_current['value']['items'].first
  10. return if !config_item
  11. return if !config_item.key?('group_id')
  12. config_item['group_ids'] = config_item.delete('group_id')
  13. setting.save!
  14. end
  15. end