user2351234
user2351234

Reputation: 975

Why do I keep getting an error when migrating database? Heroku

I am working on a rails app and I keep getting an error saying,

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

Here is the migration:

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

Upvotes: 1

Views: 1461

Answers (1)

sameera207
sameera207

Reputation: 16619

This is because one of your earlier migrations setting the index for users table, check your migrations and either remove it from there of remove this migration

Upvotes: 1

Related Questions