PGError:错误:关系“用户”的列“电子邮件”已存在
我一直在开发一个关于localhost的网站,它很好。 今天早上,我尝试使用命令“git push heroku master”将其推送到heroku,然后“heroku run rake db:migrate”。 当我尝试做第二个时,我有一个错误:
Connecting to database specified by DATABASE_URL Migrating to DeviseCreateUsers (20130427200347) Migrating to CreateAuthentications (20130427210108) Migrating to AddTokenToAuth (20130427233400) Migrating to AddNotificationToAuth (20130427234836) Migrating to AddNotifToUser (20130428031013) Migrating to AddDeviseToUsers (20130712103048) == AddDeviseToUsers: migrating =============================================== -- change_table(:users) rake aborted! An error has occurred, this and all later migrations canceled: PGError: ERROR: column "email" of relation "users" already exists : ALTER TABLE "users" ADD COLUMN "email" character varying(255) DEFAULT '' NOT N sql_adapter.rb:652:in `async_exec'
我找到了一个有同样问题的人( heroku PGError:已经存在500我们很抱歉,但出了点问题 )但在我的情况下,迁移“AddDeviseToUsers”不在’db / migrate’文件夹中。
以前的迁移影响用户表是:
class DeviseCreateUsers false, :default => "" t.string :encrypted_password, :null => false, :default => "" ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at ## Rememberable t.datetime :remember_created_at ## Trackable t.integer :sign_in_count, :default => 0 t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip t.string :last_sign_in_ip ## Token authenticatable # t.string :authentication_token t.timestamps end add_index :users, :email, :unique => true add_index :users, :reset_password_token, :unique => true end end
和
class AddNotifToUser < ActiveRecord::Migration def change add_column :users, :notif, :string end end
提前致谢 !!
编辑 –运行时回答评论 :heroku run rake db:migrate:status
up 20130427200347 Devise create users up 20130427210108 Create authentications up 20130427233400 Add token to auth up 20130427234836 Add notification to auth up 20130428031013 Add notif to user down 20130712103048 Add devise to users down 20130719091217 Create relationships . . .
我在现有模型的Devise迁移中找到了答案。
我做的是在DeviseCreateUsers迁移中注释掉这一行:
"t.string :email, :null => false, :default => """
- Heroku上的NoMethodError,但不是本地的
- heroku rake db:migrate ERROR“gem install activerecord-mysql-adapter”
- Rails 3.1生产 – Javascript加载,但不执行
- 如何在heroku上禁用资产管道?
- 如何在Cloud9 IDE dev服务器中处理Twilio回发?
- git clone heroku ssh权限被拒绝
- 在沙箱模式下在heroku上运行Rails控制台
- 在heroku上安装MaxMind GeoIP ruby库
- Heroku应用程序崩溃,在尝试heroku rake db:migrate时收到“无效的DATABASE URL”