【发布时间】:2017-11-07 00:49:55
【问题描述】:
我正在将小应用程序从 C9 部署到 github,然后再部署到 Heroku! 在 heroku 部署仪表板中,它说它已部署,但是当我打开应用程序时,它只会给我错误消息。 所以我搜索了很多 Stackoverflow 答案,并按照 Heroku 网站(https://devcenter.heroku.com/articles/sqlite3)的指示删除 sqlite3 并安装 gem pg。
我确实将 gem 'sqlite3' 替换为 gem 'pg' 并进行了 'bundle install',然后
它说我需要转换我的 config/database.yml 文件,所以我像这样替换它:
development:
adapter: postgresql
database: my_database_development
pool: 5
timeout: 5000
test:
adapter: postgresql
database: my_database_test
pool: 5
timeout: 5000
production:
adapter: postgresql
database: my_database_production
pool: 5
timeout: 5000
然后当我回到 c9 bash 并输入“rake db:create”时, 它告诉我
**rake aborted!
ActiveRecord::NoDatabaseError: FATAL: database "my_database_development" does not exist**
这个错误。
有人说 'bundle exec rake db:setup' 会起作用,所以我做了,然后它显示了
**Couldn't create database for {"adapter"=>"postgresql", "database"=>"my_database_test", "pool"=>5, "timeout"=>5000}
/home/ubuntu/workspace/db/schema.rb doesn't exist yet. Run `rake db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /home/ubuntu/workspace/config/application.rb to limit the frameworks that will be loaded.**
我不知道如何对此消息做出反应....当我输入“rake db:migrate”时,它再次显示。
rake aborted!
ActiveRecord::NoDatabaseError: FATAL: database "my_database_development" does not exist
我没有使用数据库,所以也许我可以在 'config/application.rb' 文件上尝试一些东西,但我应该怎么做呢?
【问题讨论】:
-
rake db:create然后rake db:migrate -
我已经完成了 'rake db:create',但没有像我写的那样工作......
-
做
rake db:reset -
和
rake db:setup一样的错误加上PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII) HINT: Use the same encoding as in the template database, or use template0 as template. : CREATE DATABASE "my_database_development" ENCODING = 'utf8'
标签: ruby-on-rails heroku github sqlite