debian-mirror-gitlab/db/migrate/20160119145451_add_ldap_email_to_users.rb

32 lines
847 B
Ruby
Raw Normal View History

# rubocop:disable all
2019-02-15 15:39:39 +05:30
class AddLdapEmailToUsers < ActiveRecord::Migration[4.2]
2016-01-29 22:53:50 +05:30
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