1

我正在开发一个 Rails 应用程序,但我不断收到错误消息,

AddIndexToUsersEmail: migrating ===========================================
-- add_index(:users, :email, {:unique=>true})
rake aborted!
An error has occurred, this and all later migrations canceled:

Index name 'index_users_on_email' on table 'users' already exists/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/schema_statements.rb:576:in `add_index_options'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_reco

这是迁移:

class AddIndexToUsersEmail < ActiveRecord::Migration
  def change
    add_index :users, :email, unique: true
  end
end
4

1 回答 1

1

这是因为您之前的迁移之一为users表设置了索引,检查您的迁移并从那里删除它或删除此迁移

于 2013-05-17T00:21:49.890 回答