Reputation: 217
After pushing my master branch to heroku from git, I'm now trying to migrate my db file to heroku also but I came across this error
clydiscope$ heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.6472
Migrating to DeviseCreateUsers (20141203201816)
== 20141203201816 DeviseCreateUsers: migrating ================================
-- create_table(:users)
-> 0.3488s
-- add_index(:users, :email, {:unique=>true})
-> 0.0146s
-- add_index(:users, :reset_password_token, {:unique=>true})
-> 0.0143s
== 20141203201816 DeviseCreateUsers: migrated (0.3782s) =======================
Migrating to AddNameToUsers (20141206140057)
== 20141206140057 AddNameToUsers: migrating ===================================
-- add_column(:users, :name, :string)
PG::DuplicateColumn: ERROR: column "name" of relation "users" already exists
: ALTER TABLE "users" ADD COLUMN "name" character varying(255)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::DuplicateColumn: ERROR: column "name" of relation "users" already exists
: ALTER TABLE "users" ADD COLUMN "name" character
/app/db/migrate/20141206140057_add_name_to_users.rb:3:in `up'
Apparently, there's a duplicate column that I wasn't aware of... I was continuously migrating in the development phase and it seemed to work up to this point. How can I change ,my db now so that heroku accepts it?
Here's the code from the last line.
class AddNameToUsers < ActiveRecord::Migration
def up
add_column :users, :name, :string
end
def down
remove_column :users, :name
end
end
Upvotes: 2
Views: 1116
Reputation: 9523
Probably just deleting the migration file 20141206140057_add_name_to_users.rb
will solve the problem (of course, after committing and push to Heroku).
Upvotes: 3