diff options
author | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2014-12-23 09:58:54 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2014-12-23 09:58:54 +0000 |
commit | 554719d985916d9f49f70b577382ab3a6da7eb7f (patch) | |
tree | ef2df4ee4dfe5e8d1b0ce64bbf9ef9e512fc7f9a /db | |
parent | 3eb239d6fcc9d48e029f0ef11ea95c10075c3289 (diff) | |
parent | 1440ac815435063330955a6c73ca5ba3b2304ba4 (diff) | |
download | gitlab-ce-554719d985916d9f49f70b577382ab3a6da7eb7f.tar.gz |
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
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20141121161704_add_identity_table.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/db/migrate/20141121161704_add_identity_table.rb b/db/migrate/20141121161704_add_identity_table.rb index 6fe63637dfe..a85b0426cec 100644 --- a/db/migrate/20141121161704_add_identity_table.rb +++ b/db/migrate/20141121161704_add_identity_table.rb @@ -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 |