【Renderエラー】ERROR: relation "users" does not exist at character 454

実現したいこと

Renderを使ってWebアプリをデプロイしようとしています。

発生している問題・分からないこと

デプロイには成功したのですが、Webページを開こうとすると以下のエラーが出ました。
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
ログを確認すると、DBに問題があることがわかりました。

エラーメッセージ

error

1ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "users" does not exist

該当のソースコード

render.yaml

1databases: 2 - name: Webアプリ名 3 databaseName: DB名 4 user: Webアプリ名 5 region: singapore 6 7services: 8 - type: web 9 name: Webアプリ名 10 env: ruby 11 region: singapore 12 plan: free 13 buildCommand: "./bin/render-build.sh" 14 startCommand: "bundle exec puma -C config/puma.rb" 15 envVars: 16 - key: DATABASE_URL 17 fromDatabase: 18 name: DB名 19 property: connectionString 20 - key: RAILS_MASTER_KEY 21 sync: false

render

1#!/usr/bin/env bash 2# exit on error 3set -o errexit 4bundle install 5bundle exec rake assets:precompile 6bundle exec rake assets:clean 7bundle exec rake db:migrate

database.yaml

1# SQLite. Versions 3.8.0 and up are supported. 2# gem install sqlite3 3# 4# Ensure the SQLite 3 gem is defined in your Gemfile 5# gem 'sqlite3' 6# 7default: &default 8 adapter: sqlite3 9 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 10 timeout: 5000 11 12development: 13 <<: *default 14 database: db/development.sqlite3 15 16# Warning: The database defined as "test" will be erased and 17# re-generated from your development database when you run "rake". 18# Do not set this db to the same as development or production. 19test: 20 <<: *default 21 database: db/test.sqlite3 22 23#production: 24# <<: *default 25# database: db/production.sqlite3 26 27 28#デプロイのために変更 29production: 30 <<: *default 31 adapter: postgresql 32 encoding: unicode 33 pool: 5

試したこと・調べたこと

上記の詳細・結果

一度DBをリセットすると治った事例があったため、以下のコードでリセット。改善しなかった。

bin/render

1#!/usr/bin/env bash 2# exit on error 3set -o errexit 4 5bundle install 6bundle exec rake assets:precompile 7bundle exec rake assets:clean 8# bundle exec rake db:migrate ←コメントアウト 9DISABLE_DATABASE_ENVIRONMENT_CHECK=1 bundle exec rake db:migrate:reset  #追記

補足

足りない情報があれば追加します。質問もお待ちしています。よろしくお願いします。

コメントを投稿

0 コメント