当前位置: 首页 > 知识库问答 >
问题:

试图部署到heroku时出错(遵循ror教程)PG::Error:Error:关系“users”的列“password_digest”已经存在

艾奕
2023-03-14

因此,我关注http://www.railstutorial.org/book,evrything在本地运行良好(运行sqlight3)。

当我尝试时,我会得到以下错误

PG::错误:错误:关系“users”的列“password_digest”已经存在:ALTER TABLE“users”添加列“password_digest”字符变化(255)/app/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:在中exec gems/activeRecord-4.0.8/lib/active_record/connection_adapters/abstract_adapter.rb:442:在log中的块中/app/vendor/bundle/ruby/2.0.0/gems/activeSupport-4.0.8/lib/active_support/notifications/instrumenter.rb:20:在tion_adapters/postgreSQL/database_statements.rb:127:在execute'/app/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/connection_adapters/abstract/schema_statements.rb:360:在中add_column'/app/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/connection_adapters/postgresql/schema_statements.rb:395:在中2.0.0/gems/activeRecord-4.0.8/lib/active_record/migration。RB:601:在中的块在say_with_time'/app/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/migration。RB:601:在中的say_with_time'/app/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/migration。/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/migration.rb:575:inexec_migration'/app/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/migration.rb:559:在块(2级)中的migrate'/app/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/migration.rb:558:在块中的migrate:557:在中迁移'/app/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/migration。RB:713:在中迁移'/app/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/migration。RB:963:在中迁移'/app/vendor/bundle/ruby/2.0.0/gems/activeRecord/migration。RB:1009:在ActiveRecord-4.0.8/lib/active_record/connection_adapters/abstract/database_statements.rb:203:intransact中的块ion'/app/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/connection_adapters/abstract/database_statements.rb:211:inwithin_new_transaction'/app/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/connection_adapters/abstratements.rb:203:intransaction 2.0.0/gems/activeRecord-4.0.8/lib/active_record/migration.rb:1009:inDDL_transaction'/app/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/migration.rb:962:inexecute_migration_in_transaction'/app/vendor/bundle/ruby/2.0.0/gems/active_record_in_transaction code>each'/app/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/migration.rb:920:inmigrate'/app/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/migration.rb:768:inup'/app/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/migration.rb:746:inmigrate'/app/vendor/bundle/ruby/2.0.0/gems/activeRecord-4.0.8/lib/active_record/databases

我已经尝试过heroku PG:重置DATABASE_URL,然后重试。还尝试向.slugignore添加/spec、/lib、/script、/features、/cucumber.yml

这就是我的模式的样子:

ActiveRecord::Schema.define(version: 20140818041701) do

  create_table "users", force: true do |t|
    t.string   "name"
    t.string   "email"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.string   "password_digest"
    t.string   "remember_token"
    t.boolean  "admin",           default: false
  end

  add_index "users", ["email"], name: "index_users_on_email", unique: true
  add_index "users", ["remember_token"], name: "index_users_on_remember_token"

end

这就是我的密码摘要迁移的样子

class AddPasswordDigestToUsers < ActiveRecord::Migration
  def change
    add_column :users, :password_digest, :string
  end
end

共有1个答案

董良策
2023-03-14

您的表中已经有password_digest列,而使用迁移addpassworddigesttousers时,您正试图创建另一个列,这就是它创建问题的原因。删除迁移AddPasswordDigestTousers,并再次尝试运行rake db:migrate。Sqlite3在这种情况下不会产生任何错误。如果在迁移中编写intege而不是integer,则如果使用SQLite将不会产生任何错误。

 类似资料:
  • 我目前正在学习Michael Hartl的RoR教程,尽管我仔细地遵循了说明,但我的应用程序并没有正确地部署到heroku。帮助 我的文件看起来像这样 我输入了以下命令: 然而,我的最终结果是这样的:http://warm-wildwood-5691.herokuapp.com/“您要查找的页面不存在。” 这些是我的Heroku日志 2013-07-19T19:21:15.363798 00:00

  • 块(2个级别)in 'tasks:TOP=>db:migrate(请参阅通过运行任务与--trace进行完整跟踪) 我不知道这怎么可能,因为在方案文件中我没有张贴表。

  • “tasks:TOP=>db:migrate(请参阅使用--trace运行任务的完全跟踪) 我不理解这是怎么可能的,因为在方案文件中我没有post表。

  • 我正在尝试将我的应用程序部署到Heroku,但似乎存在一些问题。每次我尝试: 我的heroku日志告诉我,我的应用程序崩溃了,我错过了“调试器”宝石。我在Heroku上找到了这条线索和这一页。当我尝试安装“byebug”gem时,bundle告诉我它不会安装在Ruby 1.9.3上,当我按照Heroku的建议将“debugger”gem放在gem文件的开发组中时,我仍然会收到相同的错误。 我也更新

  • 我有一个vuejs应用程序,它是用vue cli设置的,我正在尝试将我的应用程序部署到Heroku。 这是我的服务器: 我从gitignore中删除dist, 我在package.json中添加了一个类似“start”的起始点:“node server.js” 以下是我在控制台看到的内容: 加载资源失败:服务器响应,状态为503(服务不可用)/Favicon.ico:1 以下是heroku日志:

  • 在Heroku上部署Node.js应用程序时,我遇到以下错误。 2017-04-18T18:40:10.158442+00:00APP[Web1]:npm错误!请在任何支持请求中包含以下文件: 2017-04-18T18:40:10.158544+00:00APP[Web1]:npm错误!/app/npm-debug.log 2017-04-18T18:40:10.237236+00:00 Her