0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

database configuration does not specify adapter

Last updated at Posted at 2025-07-22

タイトルのエラーが出たので原因を探していたところ、以下が原因だった。

現状の detabase.yml

default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: <%= ENV.fetch("POSTGRES_USER") { 'default' } %>
  password: <%= ENV.fetch("POSTGRES_PASSWORD") { 'password' } %>
  host: <%= ENV.fetch("DB_HOST") { 'db' } %>

development:
  <<: *default
  database: app_dev
test:
  <<: *default
  database: app_test

production:
  primary:
    <<: *default
    url: <%= ENV["DATABASE_URL"] %>

動作した detabase.yml

default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: <%= ENV.fetch("POSTGRES_USER") { 'default' } %>
  password: <%= ENV.fetch("POSTGRES_PASSWORD") { 'password' } %>
  host: <%= ENV.fetch("DB_HOST") { 'db' } %>

development:
  <<: *default
  database: app_dev
test:
  <<: *default
  database: app_test

production:
<-- ここを修正 -->
  <<: *default
  url: <%= ENV["DATABASE_URL"] %>

このprimaryの書き方はrails 6,7あたりの記述らしく 少なくともRenderを使ったrails8の私の環境ではこの設定で良い模様
追記: solid_queueの使用時などdatabaseを2個使いたい時に使うためのものっぽい
追記: primary: &primary_development ←こういうふうに使うっぽい

こうすることでdefaultの設定が適用されると思われる

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?