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

20160119145451_add_ldap_email_to_users.rb « migrate « db - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5b2b0bd31cad9eeb83740042d9fc9d0dff95559b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# rubocop:disable all
class AddLdapEmailToUsers < ActiveRecord::Migration
  def up
    add_column :users, :ldap_email, :boolean, default: false, null: false

    if Gitlab::Database.mysql?
      execute %{
        UPDATE users, identities
        SET users.ldap_email = TRUE
        WHERE identities.user_id = users.id
        AND users.email LIKE 'temp-email-for-oauth%'
        AND identities.provider LIKE 'ldap%'
        AND identities.extern_uid IS NOT NULL
      }
    else
      execute %{
        UPDATE users
        SET ldap_email = TRUE
        FROM identities
        WHERE identities.user_id = users.id
        AND users.email LIKE 'temp-email-for-oauth%'
        AND identities.provider LIKE 'ldap%'
        AND identities.extern_uid IS NOT NULL
      }
    end
  end

  def down
    remove_column :users, :ldap_email
  end
end