20220504133218_setting_updates3.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. class SettingUpdates3 < ActiveRecord::Migration[6.1]
  3. def change
  4. return if !Setting.exists?(name: 'system_init_done')
  5. settings_update = [
  6. {
  7. name: 'idoit_integration',
  8. description: 'Defines if the i-doit (https://www.i-doit.org/) integration is enabled or not.',
  9. },
  10. {
  11. title: 'Microsoft 365 App Credentials',
  12. name: 'auth_microsoft_office365_credentials',
  13. description: 'Enables user authentication via Microsoft 365.',
  14. },
  15. ]
  16. settings_update.each do |setting|
  17. fetched_setting = Setting.find_by(name: setting[:name])
  18. next if !fetched_setting
  19. if setting[:title]
  20. # "Updating title of #{setting[:name]} to #{setting[:title]}"
  21. fetched_setting.title = setting[:title]
  22. end
  23. if setting[:description]
  24. # "Updating description of #{setting[:name]} to #{setting[:description]}"
  25. fetched_setting.description = setting[:description]
  26. end
  27. fetched_setting.save!
  28. end
  29. end
  30. end