summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2014-11-27 13:34:39 +0200
committerValery Sizov <vsv2711@gmail.com>2014-12-04 13:03:55 +0200
commit3a5ed5260b24051939575d1934ce9b8392cac09f (patch)
tree04d361e52d16234f00e5cdd27b5ebfef9a503579 /db
parent1a80d13a3990937580c97e2b0ba8fb98f69bc055 (diff)
downloadgitlab-ce-3a5ed5260b24051939575d1934ce9b8392cac09f.tar.gz
Supporting for multiple omniauth provider for the same user
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20141121161704_add_identity_table.rb17
-rw-r--r--db/schema.rb102
2 files changed, 41 insertions, 78 deletions
diff --git a/db/migrate/20141121161704_add_identity_table.rb b/db/migrate/20141121161704_add_identity_table.rb
index 7d019c65ee1..243958039af 100644
--- a/db/migrate/20141121161704_add_identity_table.rb
+++ b/db/migrate/20141121161704_add_identity_table.rb
@@ -8,14 +8,25 @@ class AddIdentityTable < ActiveRecord::Migration
add_index :identities, :user_id
- User.where("provider is not NULL").find_each do |user|
+ User.where("provider IS NOT NULL").find_each do |user|
execute "INSERT INTO identities(provider, extern_uid, user_id) VALUES('#{user.provider}', '#{user.extern_uid}', '#{user.id}')"
end
- #TODO remove user's columns extern_uid and provider
+ remove_column :users, :extern_uid
+ remove_column :users, :provider
end
def down
-#TODO
+ add_column :users, :extern_uid, :string
+ add_column :users, :provider, :string
+
+ User.where("id IN(SELECT user_id FROM identities)").find_each do |user|
+ identity = user.identities.last
+ user.extern_uid = identity.extern_uid
+ user.provider = identity.provider
+ user.save
+ end
+
+ drop_table :identities
end
end
diff --git a/db/schema.rb b/db/schema.rb
index 34f991e5cf2..ec211901e42 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -16,15 +16,6 @@ ActiveRecord::Schema.define(version: 20141121161704) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
- create_table "appearances", force: true do |t|
- t.string "title"
- t.text "description"
- t.string "logo"
- t.integer "updated_by"
- t.datetime "created_at"
- t.datetime "updated_at"
- end
-
create_table "broadcast_messages", force: true do |t|
t.text "message", null: false
t.datetime "starts_at"
@@ -83,21 +74,6 @@ ActiveRecord::Schema.define(version: 20141121161704) do
add_index "forked_project_links", ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree
- create_table "git_hooks", force: true do |t|
- t.string "force_push_regex"
- t.string "delete_branch_regex"
- t.string "commit_message_regex"
- t.boolean "deny_delete_tag"
- t.integer "project_id"
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "username_regex"
- t.string "email_regex"
- t.string "author_email_regex"
- t.boolean "member_check", default: false, null: false
- t.string "file_name_regex"
- end
-
create_table "identities", force: true do |t|
t.string "extern_uid"
t.string "provider"
@@ -162,15 +138,6 @@ ActiveRecord::Schema.define(version: 20141121161704) do
add_index "labels", ["project_id"], name: "index_labels_on_project_id", using: :btree
- create_table "ldap_group_links", force: true do |t|
- t.string "cn", null: false
- t.integer "group_access", null: false
- t.integer "group_id", null: false
- t.datetime "created_at"
- t.datetime "updated_at"
- t.string "provider"
- end
-
create_table "members", force: true do |t|
t.integer "access_level", null: false
t.integer "source_id", null: false
@@ -250,8 +217,6 @@ ActiveRecord::Schema.define(version: 20141121161704) do
t.string "type"
t.string "description", default: "", null: false
t.string "avatar"
- t.string "ldap_cn"
- t.integer "ldap_access"
end
add_index "namespaces", ["name"], name: "index_namespaces_on_name", using: :btree
@@ -283,14 +248,6 @@ ActiveRecord::Schema.define(version: 20141121161704) do
add_index "notes", ["project_id"], name: "index_notes_on_project_id", using: :btree
add_index "notes", ["updated_at"], name: "index_notes_on_updated_at", using: :btree
- create_table "project_group_links", force: true do |t|
- t.integer "project_id", null: false
- t.integer "group_id", null: false
- t.datetime "created_at"
- t.datetime "updated_at"
- t.integer "group_access", default: 30, null: false
- end
-
create_table "projects", force: true do |t|
t.string "name"
t.string "path"
@@ -298,22 +255,21 @@ ActiveRecord::Schema.define(version: 20141121161704) do
t.datetime "created_at"
t.datetime "updated_at"
t.integer "creator_id"
- t.boolean "issues_enabled", default: true, null: false
- t.boolean "wall_enabled", default: true, null: false
- t.boolean "merge_requests_enabled", default: true, null: false
- t.boolean "wiki_enabled", default: true, null: false
+ t.boolean "issues_enabled", default: true, null: false
+ t.boolean "wall_enabled", default: true, null: false
+ t.boolean "merge_requests_enabled", default: true, null: false
+ t.boolean "wiki_enabled", default: true, null: false
t.integer "namespace_id"
- t.string "issues_tracker", default: "gitlab", null: false
+ t.string "issues_tracker", default: "gitlab", null: false
t.string "issues_tracker_id"
- t.boolean "snippets_enabled", default: true, null: false
+ t.boolean "snippets_enabled", default: true, null: false
t.datetime "last_activity_at"
t.string "import_url"
- t.integer "visibility_level", default: 0, null: false
- t.boolean "archived", default: false, null: false
+ t.integer "visibility_level", default: 0, null: false
+ t.boolean "archived", default: false, null: false
t.string "import_status"
- t.float "repository_size", default: 0.0
- t.integer "star_count", default: 0, null: false
- t.text "merge_requests_template"
+ t.float "repository_size", default: 0.0
+ t.integer "star_count", default: 0, null: false
end
add_index "projects", ["creator_id"], name: "index_projects_on_creator_id", using: :btree
@@ -379,12 +335,12 @@ ActiveRecord::Schema.define(version: 20141121161704) do
end
create_table "users", force: true do |t|
- t.string "email", default: "", null: false
- t.string "encrypted_password", default: "", null: false
+ t.string "email", default: "", null: false
+ t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
- t.integer "sign_in_count", default: 0
+ t.integer "sign_in_count", default: 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
@@ -392,35 +348,32 @@ ActiveRecord::Schema.define(version: 20141121161704) do
t.datetime "created_at"
t.datetime "updated_at"
t.string "name"
- t.boolean "admin", default: false, null: false
- t.integer "projects_limit", default: 10
- t.string "skype", default: "", null: false
- t.string "linkedin", default: "", null: false
- t.string "twitter", default: "", null: false
+ t.boolean "admin", default: false, null: false
+ t.integer "projects_limit", default: 10
+ t.string "skype", default: "", null: false
+ t.string "linkedin", default: "", null: false
+ t.string "twitter", default: "", null: false
t.string "authentication_token"
- t.integer "theme_id", default: 1, null: false
+ t.integer "theme_id", default: 1, null: false
t.string "bio"
- t.integer "failed_attempts", default: 0
+ t.integer "failed_attempts", default: 0
t.datetime "locked_at"
- t.string "extern_uid"
- t.string "provider"
t.string "username"
- t.boolean "can_create_group", default: true, null: false
- t.boolean "can_create_team", default: true, null: false
+ t.boolean "can_create_group", default: true, null: false
+ t.boolean "can_create_team", default: true, null: false
t.string "state"
- t.integer "color_scheme_id", default: 1, null: false
- t.integer "notification_level", default: 1, null: false
+ t.integer "color_scheme_id", default: 1, null: false
+ 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"
t.datetime "confirmation_sent_at"
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.datetime "admin_email_unsubscribed_at"
+ t.boolean "hide_no_ssh_key", default: false
+ t.string "website_url", default: "", null: false
end
add_index "users", ["admin"], name: "index_users_on_admin", using: :btree
@@ -428,7 +381,6 @@ ActiveRecord::Schema.define(version: 20141121161704) do
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
add_index "users", ["current_sign_in_at"], name: "index_users_on_current_sign_in_at", using: :btree
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
- add_index "users", ["extern_uid", "provider"], name: "index_users_on_extern_uid_and_provider", unique: true, using: :btree
add_index "users", ["name"], name: "index_users_on_name", using: :btree
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
add_index "users", ["username"], name: "index_users_on_username", using: :btree