Commit 04f05ac1 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Check for table instead of class

parent f64db1fa
...@@ -11,13 +11,13 @@ class FixIdentities < ActiveRecord::Migration ...@@ -11,13 +11,13 @@ class FixIdentities < ActiveRecord::Migration
# the first LDAP server specified in gitlab.yml / gitlab.rb. # the first LDAP server specified in gitlab.yml / gitlab.rb.
new_provider = Gitlab.config.ldap.servers.first.last['provider_name'] new_provider = Gitlab.config.ldap.servers.first.last['provider_name']
# Delete duplicate identities # Delete duplicate identities
execute "DELETE FROM identities WHERE provider = 'ldap' AND user_id IN (SELECT user_id FROM identities WHERE 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 # Update legacy identities
execute "UPDATE identities SET provider = '#{new_provider}' WHERE provider = 'ldap';" execute "UPDATE identities SET provider = '#{new_provider}' WHERE provider = 'ldap';"
if defined?(LdapGroupLink) if table_exists?('ldap_group_links')
execute "UPDATE ldap_group_links SET provider = '#{new_provider}' WHERE provider IS NULL;" execute "UPDATE ldap_group_links SET provider = '#{new_provider}' WHERE provider IS NULL;"
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment