diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-01-19 16:25:38 +0100 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-01-19 16:25:38 +0100 |
commit | 98e1a5b63424b6912de98ee5055d3f9e57e63899 (patch) | |
tree | 773952fd630e222ec72d368f53e4a238d3d6c839 /db/migrate | |
parent | 425f8d6f572a3ae47c971a48bfefc9907c7bda55 (diff) | |
download | gitlab-ce-98e1a5b63424b6912de98ee5055d3f9e57e63899.tar.gz |
Allow LDAP users to change their email if it was not set by the LDAP server
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20160119145451_add_ldap_email_to_users.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/db/migrate/20160119145451_add_ldap_email_to_users.rb b/db/migrate/20160119145451_add_ldap_email_to_users.rb new file mode 100644 index 00000000000..654d31ab15a --- /dev/null +++ b/db/migrate/20160119145451_add_ldap_email_to_users.rb @@ -0,0 +1,30 @@ +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 |