将我的master分支从git推送到heroku之后,我现在尝试将我的db文件迁移到heroku但是我遇到了这个错误
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'
显然,有一个重复的专栏,我不知道...... 我一直在开发阶段进行迁移,它似乎在这一点上起作用。我如何更改,我的数据库现在让heroku接受它?
这是最后一行的代码。
class AddNameToUsers < ActiveRecord::Migration
def up
add_column :users, :name, :string
end
def down
remove_column :users, :name
end
end
答案 0 :(得分:3)
可能只是删除迁移文件20141206140057_add_name_to_users.rb
将解决问题(当然,在提交并推送到Heroku之后)。