diff options
-rw-r--r-- | db/migrate/20150411000035_fix_identities.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/db/migrate/20150411000035_fix_identities.rb b/db/migrate/20150411000035_fix_identities.rb index 12526b10e6e..93beb046d78 100644 --- a/db/migrate/20150411000035_fix_identities.rb +++ b/db/migrate/20150411000035_fix_identities.rb @@ -1,13 +1,15 @@ 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) + execute "DELETE FROM identities WHERE provider = 'ldap' AND user_id IN (SELECT user_id FROM identities WHERE provider = '#{new_provider}')" + + # Update legacy identities + execute "UPDATE identities SET provider = '#{new_provider}' WHERE provider = 'ldap';" if defined?(LdapGroupLink) - LdapGroupLink.where('provider IS NULL').update_all(provider: new_provider) + execute "UPDATE ldap_group_links SET provider = '#{new_provider}' WHERE provider IS NULL;" end end |