我正在尝试让Heroku Pipeline与我的Rails 7应用程序一起工作。当前遇到与数据库连接/创建相关的问题。在管道测试选项卡中,所有测试都失败,我得到以下错误:
Running 245 tests in parallel using 4 processes
We could not find your database: postgres. Which can be found in the database configuration file located at config/database.yml.
To resolve this issue:
- Did you create the database for this app, or delete it? You may need to create your database.
- Has the database name changed? Check your database.yml config has the correct database name.
To create your database, run:
bin/rails db:create
Couldn't create 'd7cd1vu5hke8mq-0' database. Please check your configuration.
[...]
DRb::DRbRemoteError: We could not find your database: postgres. Which can be found in the database configuration file located at config/database.yml.
To resolve this issue:
- Did you create the database for this app, or delete it? You may need to create your database.
- Has the database name changed? Check your database.yml config has the correct database name.
To create your database, run:
bin/rails db:create
(ActiveRecord::NoDatabaseError)
我对Heroku CI和Pipelines总体来说是相当陌生的。我的config/database.yml
文件看起来像这样:
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: postgres
password: <%= ENV['WS_DATABASE_PASSWORD'] %>
port: 5432
development:
<<: *default
database: db/development
# 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:
<<: *default
database: db/test
production:
<<: *default
database: db/production
我的生产数据库工作正常,但在Heroku上运行测试时出现错误。
我还创建了一个app.json
文件,但这也没有帮助:
{
"environments": {
"test": {
"addons":[
"heroku-postgresql:mini",
"heroku-redis:mini"
]
}
}
}
关于为什么我的数据库连接和测试套件不能正常运行有什么想法吗?
1条答案
按热度按时间okxuctiv1#
删除
database.yml
中的user
、password
和port
设置,这里有一个可靠的文档解释why
:Rails Database Connection Behavior使用
heroku-postgresql:in-dyno
插件在app.json
中进行postgres测试,如下所述:Heroku CI In-Dyno Databases .你会希望你的Redis测试环境也是这样。