Heroku生产错误:PG ::错误:错误:关系"用户"已经存在错误 [英] Heroku Production Error: PG::Error: ERROR: relation "users" already exists error

查看:125
本文介绍了Heroku生产错误:PG ::错误:错误:关系"用户"已经存在错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常像拔牙一样部署到Heroku?我一直在尝试一个星期,错误发生后是错误的。我已经联系Heroku支持,他们建议我尝试使用stackoverflow。所以在这里。



我按照指南将我的Devise升级到2.0架构: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to -Devise-2.0-migration-schema-style



请参阅以下代码库:www.github.com/apane/blogit_blog



我现在有下面的错误(这应该是em'的最后一个)

   -  -  create_table(:users)
注意:CREATE TABLE将为串行列users.id创建隐式序列users_id_seq1
rake中止!
发生错误,此次以及所有后来的迁移都被取消:

PG ::错误:错误:关系用户已经存在
:CREATE TABLEusers(id (255)DEFAULT''NOT NULL,'encrypted_pa​​ssword'字符变化(255)DEFAULT''NOT NULL,reset_password_token字符变化(255),reset_password_sent_at时间戳,remember_created_at时间戳,sign_in_count整数DEFAULT 0,current_sign_in_at时间戳,last_sign_in_at时间戳,current_sign_in_ip字符变化(255),last_sign_in_ip字符变化(255),created_at时间戳NOT NULL,updated_at时间戳NOT NULL )/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:650:in`exec'
/ app / vendor / bundle / ruby /1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:650:in`block in execute'
/app/vendor/bundle/ruby/1.9.1/gems/ activer ecord-3.2.13 / lib / active_record / connection_adapters / abstract_adapter.rb:280:在`block in log'中
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib /active_support/notifications/instrumenter.rb:20:in`instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb: 275:在`log'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:649:in`execute'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/schema_statements.rb:170:in`create_table'
/ app / vendor / bundle /ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:466:in`method in method_missing'
/app/vendor/bundle/ruby/1.9.1/gems/ activerecord-3.2.13 / lib / active_record / migration.rb:438:在`block in say_with_time'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record /migration.rb:438:in` say_with_time'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:458:in`method_missing'
/ app / vendor / bundle / ruby​​ / 1.9.1 / gems / activerecord-3.2.13 / lib / active_record / migration.rb:334:在`method_missing'
/app/db/migrate/20130529023532_devise_create_users.rb:3:in`up '
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:370:in'up'
/ app / vendor / bundle /ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:410:in`block(2 levels)in migrate'
/app/vendor/bundle/ruby/1.9。 1 / gems / activerecord-3.2.13 / lib / active_record / migration.rb:410:在`block in migrate'中
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13 /lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in`with_connection'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration。 rb:389:在`migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/l ib / active_record / migration.rb:528:在'migrate'中
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:720:in `迁移中的块(2级)'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:775:in`call'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:775:in`block in ddl_transaction'
/ app / vendor / bundle / ruby / 1.9.1 / gems / activerecord-3.2.13 / lib / active_record / connection_adapters / abstract / database_statements.rb:192:在'transaction'中
/app/vendor/bundle/ruby/1.9.1/gems /activerecord-3.2.13/lib/active_record/transactions.rb:208:in`transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/ migration.rb:775:在`ddl_transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:719:in`block in migrate '
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/mi gration.rb:700:在`each'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:700:in' migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:570:in'up'
/ app / vendor / bundle / ruby /1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:551:in`migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2。 13 / lib / active_record / railties / databases.rake:193:在< top(必填)>中的block(2 levels)中'
/app/vendor/bundle/ruby/1.9.1/gems/ rake-10.0.4 / lib / rake / task.rb:246:在`call'中
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task .rb:246:在`block in execute'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in`each'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in`execute'
/ app / vendor / bundle / ruby / 1.9.1 / gems / rake-10.0.4 / lib / rake / task.rb:184:在`block in invoke_with_call_chain'
/ app / vendor / bundle / r uby / 1.9.1 / gems / rake-10.0.4 / lib / rake / task.rb:177:在`invoke_with_call_chain'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0 .4 / lib / rake / task.rb:170:在`invoke'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb: 143:在`invoke_task'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in`block(2 levels)in top_level '
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in`each'
/ app / vendor / bundle /ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in`block in top_level'
/app/vendor/bundle/ruby/1.9.1/gems/ rake-10.0.4 / lib / rake / application.rb:110:在`run_with_threads'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application .rb:95:在`top_level'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:73:in`block in run'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:160:in`standard_exception_handling'
/ a pp / vendor / bundle / ruby​​ / 1.9.1 / gems / rake-10.0.4 / lib / rake / application.rb:70:在`run'
任务:TOP => db:migrate
(通过使用-trace运行任务来查看完整跟踪)


解决方案

我查看了您的代码,并在空数据库上运行了数据库迁移。你的迁移似乎没有问题。但是,在你的错误中的这一行:

  PG ::错误:错误:关系用户已经存在

表明您可能没有使用全新的数据库。假设您没有任何关键任务存储在数据库中的数据,最好的办法就是放弃数据库并重新开始。所以,如果你运行:

  heroku pg:reset blog_production 

(假设您正在以生产模式进行部署),您将拥有全新的数据库。然后只需要:

  heroku run rake db:migrate 

,你应该回到正轨。


Is deploying to Heroku typically like pulling teeth? I've been trying for a week now and it's error after error. I've contacted Heroku support and they suggested I try stackoverflow. So here it goes.

I've just upgraded my Devise to 2.0 schema following the guide: https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.0-migration-schema-style .

See the codebase here: www.github.com/apane/blogit_blog

I now have the following error (this should be the last of em')

-- create_table(:users)
NOTICE:  CREATE TABLE will create implicit sequence "users_id_seq1" for serial column "users.id"
rake aborted!
An error has occurred, this and all later migrations canceled:

PG::Error: ERROR:  relation "users" already exists
: CREATE TABLE "users" ("id" serial primary key, "email" character varying(255) DEFAULT '' NOT NULL, "encrypted_password" character varying(255) DEFAULT '' NOT NULL, "reset_password_token" character varying(255), "reset_password_sent_at" timestamp, "remember_created_at" timestamp, "sign_in_count" integer DEFAULT 0, "current_sign_in_at" timestamp, "last_sign_in_at" timestamp, "current_sign_in_ip" character varying(255), "last_sign_in_ip" character varying(255), "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) /app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:650:in `exec'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:650:in `block in execute'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:649:in `execute'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/schema_statements.rb:170:in `create_table'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:466:in `block in method_missing'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:438:in `block in say_with_time'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:438:in `say_with_time'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:458:in `method_missing'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:334:in `method_missing'
/app/db/migrate/20130529023532_devise_create_users.rb:3:in `up'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:370:in `up'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:410:in `block (2 levels) in migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:410:in `block in migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:129:in `with_connection'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:389:in `migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:528:in `migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:775:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:775:in `block in ddl_transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/transactions.rb:208:in `transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:775:in `ddl_transaction'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:719:in `block in migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:700:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:700:in `migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:570:in `up'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/migration.rb:551:in `migrate'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:193:in `block (2 levels) in <top (required)>'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/app/vendor/bundle/ruby/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

解决方案

I took a look at your code, and ran the database migrations on an empty database. Your migrations seem to be fine. However, this line in your error:

PG::Error: ERROR:  relation "users" already exists

suggests that you might not be working from a fresh database. Assuming you don't have any data that's mission-critical stored in your database, your best bet is just to drop the database and start over. So, if you run:

heroku pg:reset blog_production

(assuming you're deploying in production mode) you'll have a fresh database. Then just do:

heroku run rake db:migrate

and you should be back on track.

这篇关于Heroku生产错误:PG ::错误:错误:关系&quot;用户&quot;已经存在错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆