incorrect database name in Rails app when containerized using docker-compose

I have a rails app that I’m trying to containerize locally using docker-compose. I am consistently getting a “database does not exist” error from docker-compose but the database name is a name I’m no longer using. Here is the error message:

db-1 | 2024-08-02 20:41:07.758 UTC [187] FATAL: database “climate_control” does not exist

The project is named “Climate Control” and the databases are named following the convention “climate_control_[environment name]” – this is my database.yml file:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>default: &default
adapter: postgresql
encoding: unicode
pool: 5
development:
<<: *default
host: db
database: climate_control_development
username: <%= ENV['POSTGRES_USER'] %>
password: <%= ENV['POSTGRES_PASSWORD'] %>
# 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: climate_control_test
username: climate_control
password: temp
production:
database: climate_control_prod
username: climate_control
password: temp
</code>
<code>default: &default adapter: postgresql encoding: unicode pool: 5 development: <<: *default host: db database: climate_control_development username: <%= ENV['POSTGRES_USER'] %> password: <%= ENV['POSTGRES_PASSWORD'] %> # 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: climate_control_test username: climate_control password: temp production: database: climate_control_prod username: climate_control password: temp </code>
default: &default
  adapter: postgresql
  encoding: unicode
  pool: 5

development:
  <<: *default
  host: db
  database: climate_control_development
  username: <%= ENV['POSTGRES_USER'] %>
  password: <%= ENV['POSTGRES_PASSWORD'] %>

# 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: climate_control_test
  username: climate_control
  password: temp

production:
  database: climate_control_prod
  username: climate_control
  password: temp

Nothing named just “climate_control” in there. I do have a user named “climate_control”, but I can’t see how that would affect the name of the database the project is trying to use.

I am specifying some environment variables (POSTGRES_DB, POSTGRES_USER, and POSTGRES_PASSWORD) in docker-compose.yml, but POSTGRES_DB is set correctly. Here is the entire file:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code># version: '3' # obsolete
services:
web:
build: .
command: bundle exec puma -C config/puma.rb
volumes:
- .:/app
ports:
- "3000:3000"
- "3001:3001" # for debugging
depends_on:
- db
environment:
RAILS_ENV: development
db:
image: postgres:14
volumes:
- /opt/homebrew/var/postgresql@16:/var/lib/postgresql/data
environment:
POSTGRES_DB: climate_control_development
POSTGRES_USER: climate_control
POSTGRES_PASSWORD: temp
healthcheck:
test: ["CMD-SHELL", "pg_isready -U climate_control"]
interval: 10s
timeout: 5s
retries: 5
</code>
<code># version: '3' # obsolete services: web: build: . command: bundle exec puma -C config/puma.rb volumes: - .:/app ports: - "3000:3000" - "3001:3001" # for debugging depends_on: - db environment: RAILS_ENV: development db: image: postgres:14 volumes: - /opt/homebrew/var/postgresql@16:/var/lib/postgresql/data environment: POSTGRES_DB: climate_control_development POSTGRES_USER: climate_control POSTGRES_PASSWORD: temp healthcheck: test: ["CMD-SHELL", "pg_isready -U climate_control"] interval: 10s timeout: 5s retries: 5 </code>
# version: '3' # obsolete
services:
  web:
    build: .
    command: bundle exec puma -C config/puma.rb
    volumes:
      - .:/app
    ports:
      - "3000:3000"
      - "3001:3001" # for debugging
    depends_on:
      - db
    environment:
      RAILS_ENV: development
  db:
    image: postgres:14
    volumes:
      - /opt/homebrew/var/postgresql@16:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: climate_control_development
      POSTGRES_USER: climate_control
      POSTGRES_PASSWORD: temp
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U climate_control"]
      interval: 10s
      timeout: 5s
      retries: 5

I have tried rebuilding the docker images:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>docker-compose down
docker-compose up --build
</code>
<code>docker-compose down docker-compose up --build </code>
docker-compose down
docker-compose up --build

I have cleared the Rails cache:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>docker-compose exec web rails tmp:cache:clear
</code>
<code>docker-compose exec web rails tmp:cache:clear </code>
docker-compose exec web rails tmp:cache:clear

I have removed everything from the tmp/ directory:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>rm -rf tmp/*
</code>
<code>rm -rf tmp/* </code>
rm -rf tmp/*

I have searched the codebase for all instances of the string “climate_control” and found only the user names. The entire project is viewable at https://github.com/fredwillmore/climate-control – there’s nothing proprietary about it, I’m just trying to create a resume project.

I’m out of ideas, I would welcome any recommendations!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật