20170113000002_slack_group_config_issue_587.rb 569 B

12345678910111213141516171819202122
  1. class SlackGroupConfigIssue587 < ActiveRecord::Migration[4.2]
  2. def up
  3. # return if it's a new setup
  4. return if !Setting.exists?(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