diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-04-13 17:18:02 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-04-13 17:18:02 +0300 |
commit | 4ab717ea6a65beca3e069ca8590c22c49085dc8c (patch) | |
tree | 80f163711240e5f6b7288be276c05f2df80a39ca /db | |
parent | ecb58dacd614de66c00c8df673abb96fafa5d452 (diff) | |
parent | f39b150a02836f620fe77e1731064b5e6e01b5b1 (diff) |
Merge branch 'ldap_migration'
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Conflicts:
db/schema.rb
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20150411000035_fix_identities.rb | 32 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 33 insertions, 1 deletions
diff --git a/db/migrate/20150411000035_fix_identities.rb b/db/migrate/20150411000035_fix_identities.rb new file mode 100644 index 00000000000..8f11a96ab01 --- /dev/null +++ b/db/migrate/20150411000035_fix_identities.rb @@ -0,0 +1,32 @@ +class FixIdentities < ActiveRecord::Migration + def up + # Up until now, legacy 'ldap' references in the database were charitably + # interpreted to point to the first LDAP server specified in the GitLab + # configuration. So if the database said 'provider: ldap' but the first + # LDAP server was called 'ldapmain', then we would try to interpret + # 'provider: ldap' as if it said 'provider: ldapmain'. This migration (and + # accompanying changes in the GitLab LDAP code) get rid of this complicated + # behavior. Any database references to 'provider: ldap' get rewritten to + # whatever the code would have interpreted it as, i.e. as a reference to + # the first LDAP server specified in gitlab.yml / gitlab.rb. + new_provider = if Gitlab.config.ldap.enabled + first_ldap_server = Gitlab.config.ldap.servers.values.first + first_ldap_server['provider_name'] + else + 'ldapmain' + end + + # 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 table_exists?('ldap_group_links') + execute "UPDATE ldap_group_links SET provider = '#{new_provider}' WHERE provider IS NULL OR provider = 'ldap';" + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 2974d3754f3..48f1b2ac2cc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -460,6 +460,7 @@ ActiveRecord::Schema.define(version: 20150411180045) do t.integer "notification_level", default: 1, null: false t.datetime "password_expires_at" t.integer "created_by_id" + t.datetime "last_credential_check_at" t.string "avatar" t.string "confirmation_token" t.datetime "confirmed_at" @@ -467,7 +468,6 @@ ActiveRecord::Schema.define(version: 20150411180045) do t.string "unconfirmed_email" t.boolean "hide_no_ssh_key", default: false t.string "website_url", default: "", null: false - t.datetime "last_credential_check_at" t.string "github_access_token" t.string "gitlab_access_token" t.string "notification_email" |