Commit 554719d9 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'fix-mysql-migration' into 'master'

Fix mysql migration

Fixes exception noted in https://gitlab.com/gitlab-org/gitlab-ce/issues/913

```
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
== 20141121161704 AddIdentityTable: migrating =================================
-- create_table(:identities)
   -> 0.1214s
-- add_index(:identities, :user_id)
   -> 0.1660s
-- execute("INSERT INTO identities (provider, extern_uid, user_id)\nSELECT provider, extern_uid, id FROM users\nWHERE provider IS NOT NULL\n")
   -> 0.0518s
-- remove_column(:users, :extern_uid)
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

Mysql2::Error: Duplicate entry 'ldap' for key 'index_users_on_extern_uid_and_provider': ALTER TABLE `users` DROP `extern_uid`/home/git/gitlab/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:301:in `query'
/home/git/gitlab/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:301:in `block in execute'
```

See merge request !1344
parents 3eb239d6 1440ac81
......@@ -14,6 +14,10 @@ SELECT provider, extern_uid, id FROM users
WHERE provider IS NOT NULL
eos
if index_exists?(:users, ["extern_uid", "provider"])
remove_index :users, ["extern_uid", "provider"]
end
remove_column :users, :extern_uid
remove_column :users, :provider
end
......@@ -34,5 +38,9 @@ eos
end
drop_table :identities
unless index_exists?(:users, ["extern_uid", "provider"])
add_index "users", ["extern_uid", "provider"], name: "index_users_on_extern_uid_and_provider", unique: true, using: :btree
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment