运行heroku run rake db:migrate时出错

问题描述 投票:0回答:2

我正在浏览Railstutorial并在运行heroku run rake db:migrate时出现错误

我已经在网上搜索了几个小时 - 这个错误似乎很常见,但建议的解决方案似乎都没有任何区别,我们非常感谢您的帮助!

错误是

Connecting to database specified by DATABASE_URL
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)

我跑了gem install activerecord-postgresql-adapter并更改了我的gemfile,它现在看起来像这样:

group :development do
  gem 'rspec-rails', '2.6.1'
  gem 'sqlite3', '~> 1.3.0'
end

group :test do
  gem 'rspec-rails', '2.6.1'
  gem 'webrat', '0.7.1'
  gem 'sqlite3', '~> 1.3.0'
end

group :production do
   gem "pg"
end

提交后我跑了bundle install --without productiongit push heroku

我的database.yml看起来像这样:

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000
ruby-on-rails heroku railstutorial.org
2个回答
0
投票

运行bundle install然后推送到heroku

省略--without production,这样gemfile.lock可以用gem pg实现


0
投票

我使用Windows系统时遇到了同样的错误。在Ubuntu虚拟机上尝试过,由于某种原因,错误消失了,因为我能够

© www.soinside.com 2019 - 2024. All rights reserved.