20220124124658_permission_updates.rb 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. class PermissionUpdates < ActiveRecord::Migration[6.0]
  3. def change
  4. return if !Setting.exists?(name: 'system_init_done')
  5. permissions_update = [
  6. {
  7. name: 'admin.channel_formular',
  8. preferences: {
  9. translations: ['Channel - Form']
  10. },
  11. },
  12. {
  13. name: 'admin.knowledge_base',
  14. note: 'Create and set up %s',
  15. },
  16. ]
  17. permissions_update.each do |permission|
  18. fetched_permission = Permission.find_by(name: permission[:name])
  19. next if !fetched_permission
  20. if permission[:note]
  21. # p "Updating note of #{permission[:name]} to #{permission[:note]}"
  22. fetched_permission.note = permission[:note]
  23. end
  24. if permission[:preferences]
  25. # p "Updating preferences of #{permission[:name]} to #{permission[:preferences]}"
  26. fetched_permission.preferences = permission[:preferences]
  27. end
  28. fetched_permission.save!
  29. end
  30. end
  31. end