diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-04-11 17:56:45 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-04-11 17:56:45 +0300 |
commit | 8666f497ff13c100f6cd2339971e430dbf05470f (patch) | |
tree | ac54df95998d2f9d67764171ad29255af5d1b532 /db/migrate | |
parent | 24d139ba971cf61a4b7a01031c4c57bcba29b172 (diff) | |
download | gitlab-ce-8666f497ff13c100f6cd2339971e430dbf05470f.tar.gz |
fix ldap identities
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20150411000035_fix_identities.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/db/migrate/20150411000035_fix_identities.rb b/db/migrate/20150411000035_fix_identities.rb new file mode 100644 index 00000000000..12526b10e6e --- /dev/null +++ b/db/migrate/20150411000035_fix_identities.rb @@ -0,0 +1,16 @@ +class FixIdentities < ActiveRecord::Migration + def up + new_provider = Gitlab.config.ldap.servers.first.last['provider_name'] + # Delete duplicate identities + Identity.connection.select_one("DELETE FROM identities WHERE provider = 'ldap' AND user_id IN (SELECT user_id FROM identities WHERE provider = '#{new_provider}')") + # Update legacy identities + Identity.where(provider: 'ldap').update_all(provider: new_provider) + + if defined?(LdapGroupLink) + LdapGroupLink.where('provider IS NULL').update_all(provider: new_provider) + end + end + + def down + end +end |