20220922090123_issue4243_permission_fix.rb 470 B

1234567891011121314151617
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class Issue4243PermissionFix < ActiveRecord::Migration[6.1]
  3. def change
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. Role.find_each do |role|
  7. next if role.groups.blank?
  8. agent_permission = Permission.find_by(name: 'ticket.agent')
  9. next if role.permissions.include?(agent_permission)
  10. role.groups = []
  11. end
  12. end
  13. end