在Heroku和Rails上不推荐使用PGconn,PGresult和PGError常量

sam*_*bay 2 sql postgresql ruby-on-rails heroku

我在数据库设置中重置Heroku上的数据库并运行heroku run rake db:migrate.尽管它为每个本地数据库创建了具有正确列的所有数据表,但它不会迁移任何现有本地数据.Heroku数据库只是空的.在过去我运行上面的代码并且工作正常,但这次卡住了如下所示:

mac-a:skiny ran$ heroku run bundle exec rake db:migrate
Running bundle exec rake db:migrate on ? blooming-citadel-66205... up, run.3076 (Hobby)
The PGconn, PGresult, and PGError constants are deprecated, and will be
removed as of version 1.0.

You should use PG::Connection, PG::Result, and PG::Error instead, respectively.

Called from /app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
ActiveRecord::SchemaMigration Load (1.2ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Run Code Online (Sandbox Code Playgroud)

作为一个注释,我在运行时退出mac终端heroku run rake db:reset,也许有一些内部错误......

foo*_*dev 7

尝试以下操作,编辑您的Gemfile,如下所示

gem 'pg', '~> 0.20.0'
Run Code Online (Sandbox Code Playgroud)

要么

gem 'pg', '~> 0.11'
Run Code Online (Sandbox Code Playgroud)

然后捆绑安装并尝试,它正在我手上.

注意:在>之前的波形符号,这不是破折号

在Gemfile的组生成中进行此更新后,请确保运行bundle install --without production(更新Gemfile.lock文件),执行git add/commit循环,然后重新部署到Heroku.

希望能帮助到你