20210729183242_set_user_source_ldap_from_external_sync.rb 435 B

12345678910111213141516
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class SetUserSourceLdapFromExternalSync < ActiveRecord::Migration[6.0]
  3. def change
  4. return if !Setting.exists?(name: 'system_init_done')
  5. ldap_user_ids = ExternalSync.where(
  6. source: 'Ldap::User',
  7. object: 'User'
  8. ).pluck(:o_id)
  9. User.where(id: ldap_user_ids).find_each do |user|
  10. user.update!(source: 'Ldap')
  11. end
  12. end
  13. end