trabajo-afectivo/db/migrate/20180911064647_issue_2140_reset_ldap_config.rb

19 lines
635 B
Ruby
Raw Normal View History

# ATTENTION: This migration is most likely not required anymore
# because the encoding error was fixed by using a newer version of the psych gem (3.1.0).
# However, we'll keep it as a regression test.
class Issue2140ResetLdapConfig < ActiveRecord::Migration[5.1]
def up
# return if it's a new setup
return if !Setting.find_by(name: 'system_init_done')
ldap_config = Setting.get('ldap_config')
# finish if LDAP config isn't broken
ldap_config.to_json
rescue Encoding::UndefinedConversionError
ldap_config[:wizardData].delete(:backend_user_attributes)
Setting.set('ldap_config', ldap_config)
end
end