Welcome to mirror list, hosted at ThFree Co, Russian Federation.

20150411000035_fix_identities.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 93beb046d780cedf1819af555157087aa5ae9223 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class FixIdentities < ActiveRecord::Migration
  def up
    new_provider = Gitlab.config.ldap.servers.first.last['provider_name']

	  # Delete duplicate identities
    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)
      execute "UPDATE ldap_group_links SET provider = '#{new_provider}' WHERE provider IS NULL;"
    end
  end

  def down
  end
end